Skip to main content

GATE CSE 2023Theory of Computation › Context-Free Languages & Pushdown AutomataVerified

GATE CSE 2023 PYQ: Consider the pushdown automaton (PDA) P \text{(PDA)}\;P (PDA) P below, which runs on the input alphabet { a…

Consider the pushdown automaton (PDA)  P\text{(PDA)}\;P below, which runs on the input alphabet {a,b}\{a, b\}, has stack alphabet {⊥,A}\{\perp, A\}, and has three states {s,p,q}\{s, p, q\}, with ss being the start state. A transition from state uu to state vv, labelled c/X/γc / X / \gamma, where cc is an input symbol or ϵ,X\epsilon, X is a stack symbol, and γ\gamma is a string of stack symbols, represents the fact that in state uu, the (PDA)\text{(PDA)} can read cc from the input, with XX on the top of its stack, pop XX from the stack, push in the string γ\gamma on the stack, and go to state vv. In the initial configuration, the stack has only the symbol ⊥\perp in it. The (PDA)\text{(PDA)} accepts by empty stack.

GATE CSE 2023 Context-Free Languages & Pushdown Automata diagram: Consider the pushdown automaton (PDA) P \text{(PDA)}\;P (PDA

Which one of the following options correctly describes the language accepted by P?P ?

  1. A
    {ambn∣1≤m\left\{a^{m} b^{n} \mid 1 \leq m\right. and n<m}\left.n \lt m\right\}
    Correct answer
  2. B
    {ambn∣0≤n≤m}\left\{a^{m} b^{n} \mid 0 \leq n \leq m\right\}
  3. C
    {ambn∣0≤m\left\{a^{m} b^{n} \mid 0 \leq m\right. and 0≤n}\left.0 \leq n\right\}
  4. D
    {am∣0≤m}∪{bn∣0≤n}\left\{a^{m} \mid 0 \leq m\right\} \cup\left\{b^{n} \mid 0 \leq n\right\}

Answer

(A) { a m b n ∣ 1 ≤ m \left\{a^{m} b^{n} \mid 1 \leq m\right. { a m b n ∣ 1 ≤ m and n < m } \left.n \lt m\right\} n < m }

Approach

Trace the PDA's stack behaviour symbol by symbol. Since the PDA accepts by empty stack, the input is accepted iff the run ends with an empty stack. The bottom marker ⊥ can only be popped in state q, and reaching q requires an A on top of the stack. Observing that each a pushes one A while each b consumes one A tells us the answer is the set of strings with strictly more a's than b's, and at least one a.

Tracing the PDA shows each a pushes one A and each b consumes one A; the only way to empty the stack is to enter q via ε/A/ε (needing an A on top) and then pop all remaining A's and ⊥. This forces m ≥ 1 and n &lt; m, exactly the language ${a^m b^n | 1 ≤ m and n \&lt; m}$, i.e. option A. The three community answers all reach the same conclusion, differing only in the level of detail and phrasing.

Reviewed by GateIQ Editorial Team: IIT & IISc Alumni.