GATE / CS ARCHIVE

GATE CSE 2023 / QUESTION 40

GATE CSE 2023 Q40

Theory of Computation · Pushdown Automata · Full GATE CSE 2023 paper

GATE 2023, Q40 2 marks · MCQ
Report issue

Pushdown Automata

Question 40, GATE 2023: An empty-stack-accepting PDA starts in s with stack ⊥. In s, a/⊥/A⊥ and a/A/AA push one A. Transition s→p and the loop at p are b/A/ε. Transitions s→q and p→q are ε/A/ε. At q, ε/A/ε and ε/⊥/ε empty the stack. Describe its accepted language over {a,b}, consuming all input.
Tap to enlarge
Your answer
Answer & solution

Official answer: A

In s each a pushes A. The first b moves to p and pops A, and further b’s pop more A. Entry to the cleanup state q requires an A at the stack top and pops it, so at least one A must remain after all input has been read. Then q removes the remaining stack symbols, including the bottom marker. Consequently input is aᵐbⁿ with m≥1 and 0≤n<m, option A. Equal counts leave only the bottom symbol in s/p and cannot enter q; epsilon is not accepted.

Teaching detail. After reading m a's, the stack is Am⊥. Reading n b's pops n A's, leaving Am−n⊥. The only gateway to the cleanup state consumes one further A without consuming input, which is possible precisely when m−n≥1. Cleanup cannot read more input, so all a's and b's must already have been consumed. Pure a strings with m≥1 are accepted via s→q; the empty string is not, because no transition from s pops ⊥ directly. The strict inequality n<m, not n≤m, is therefore essential.

Original paper, page 41 · Answer key