Question

Consider the following languages:
L1={anbmcn+m∣m,n≥1}L_1 = \{a^n b^m c^{n+m} \mid m, n \ge 1\}
L2={anbnc2n∣n≥1}L_2 = \{a^n b^n c^{2n} \mid n \ge 1\}

Which one of the following is TRUE?

Choose one option
Official answer and solution
Official answer
B
From
Official GATE 2016 answer key

Solution

Determine whether each language can be recognized by a single-stack pushdown automaton.

Analyze L1={anbmcn+m∣m,n≥1}L_1 = \{a^n b^m c^{n+m} \mid m, n \ge 1\}:
Notice that cn+mc^{n+m} contains m+nm + n copies of cc. We can recognize L1L_1 with a deterministic pushdown automaton (DPDA):

  1. Push each incoming aa onto the stack (recording nn).
  2. Push each incoming bb onto the stack (recording mm).
  3. For each incoming cc, pop a bb from the stack until all bb's are matched, then continue popping an aa for each subsequent cc until all aa's are matched.
  4. If the stack is empty exactly when the input ends, accept.
    Because a PDA with a single stack accepts L1L_1, L1L_1 is context-free (in fact, a deterministic CFL). A CFG for L1L_1 is:
S→aSc∣aAcS \to aSc \mid aAc
A→bAc∣bcA \to bAc \mid bc

Analyze L2={anbnc2n∣n≥1}L_2 = \{a^n b^n c^{2n} \mid n \ge 1\}:
Here, the number of aa's, bb's, and cc's are all tied to the same count nn. A pushdown automaton cannot simultaneously verify that the number of aa's equals the number of bb's and that the number of cc's equals twice that number using a single stack.

Applying the Pumping Lemma for CFLs to L2L_2: Let pp be the pumping length and choose z=apbpc2p∈L2z = a^p b^p c^{2p} \in L_2. Any decomposition z=uvwxyz = uvwxy with ∣vwx∣≤p|vwx| \le p and ∣vx∣≥1|vx| \ge 1 can contain at most two distinct symbols among {a,b,c}\{a, b, c\}. Pumping vv and xx alters the counts of at most two symbol types while leaving the third unchanged, producing strings not in L2L_2. Hence, L2L_2 is not context-free.

Therefore, L1L_1 is context-free while L2L_2 is not context-free.

Final answer

B

Common trap

Thinking that three variables in anbmcn+ma^n b^m c^{n+m} require two stacks, missing that the reverse order of popping allows matching both bmb^m and ana^n against cm+nc^{m+n}.

The answer is the one in the official GATE answer key. The solution is this site's own explanation.

Source

Paper
GATE 2016 Computer Science and Information Technology (CS) Session 2
Question
53 of 65, printed as CS Q.43
Section
Computer Science and Information Technology

Report an error in this question

GATE questions are the work of the organising institutes. This site is independent and is not affiliated with them.