GATE / CS ARCHIVE

GATE CSE 2016 SET 1 / QUESTION 43

GATE CSE 2016 Set 1 Q43

Theory of Computation · Pushdown Automata · Full GATE CSE 2016 Set 1 paper

GATE 2016 Set 1, Q43 2 marks · MCQ
Report issue

Pushdown Automata

Question 43, GATE 2016: A PDA over input {a,b}, stack {X,Z}, starts with stack Z. Its start state q0 and state q2 are accepting; q1 is not. q0 loops on a,X/XX and a,Z/XZ; q0→q1 is b,X/ε; q1 loops on b,X/ε; q1→q2 is ε,Z/Z. There are no other transitions. Acceptance is by final state after consuming the whole input. Which statement is true? A:L={a^n b^n:n≥0}, not finite-automaton recognizable. B:L=a* union {a^n b^n:n≥0}, not accepted by any deterministic PDA. C:L is not accepted by any Turing machine halting on all inputs. D:L=a* union {a^n b^n:n≥0}, and is deterministic context-free.
Tap to enlarge
Your answer
Answer & solution

Official answer: D

The initial state is accepting, so epsilon and every a-only word are accepted while pushing one X per a. On the first b the machine moves to the middle state and pops one X per b; it reaches the final accepting state only when the stack returns to Z. Therefore the additional accepted words are an bn. The displayed machine is deterministic: at each state/stack combination the input transitions do not compete with epsilon transitions. The language is a* union {an bn: n≥0}, a deterministic CFL, D.

Final-state acceptance does not require an empty stack. This is why an all-a input is accepted in q0 even with X symbols left above Z, and why the double circle on the start state matters. Once a b occurs the machine cannot return to q0 or read further a symbols. It can reach q2 exactly after the number of b symbols matches the pushed X count. At q1, b-transitions require top X whereas the ε-transition requires top Z, so they are never simultaneously enabled; determinism is preserved.

Original paper, page 17 · Answer key