GATE / CS ARCHIVE

GATE CSE 2020 / QUESTION 10

GATE CSE 2020 Q10

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

GATE 2020, Q10 1 mark · MCQ
Report issue

Pushdown Automata

Question 10, GATE 2020: L={a^n:n≥0}∪{a^n b^n:n≥0}. Test I L is deterministic context-free; II L is context-free but not deterministic context-free; III L is not LL(k) for any k. Options: A I only; B II only; C I and III; D III only.
Question 10, GATE 2020: L={a^n:n≥0}∪{a^n b^n:n≥0}. Test I L is deterministic context-free; II L is context-free but not deterministic context-free; III L is not LL(k) for any k. Options: A I only; B II only; C I and III; D III only.
Tap to enlarge
Your answer
Answer & solution

Official answer: C

Worked explanation

A deterministic pushdown recognizer can use an accepting a-phase, initially with a bottom marker. Each a pushes one marker. Seeing the first b changes permanently to a b-phase and pops one marker per b; a b with no marker, or any later a, rejects. At end-of-input it accepts either the a-phase (including ε) or the b-phase with exactly the bottom marker left. This establishes I constructively and rejects II. The familiar non-LL(k) separation is a language-level result: do not infer it merely because the obvious grammar S→A|B, A→aA|ε, B→aBb|ε has a FIRST-set conflict. The shared-prefix argument below explains the obstruction; a full formal proof that no equivalent LL(k) grammar exists requires the bounded-lookahead language theorem, not just testing that one grammar. III is the standard classification used by the official answer.

Derivation and answer

A DPDA pushes while reading a symbols, then pops one per b after the first b. It accepts an all-a input by final state at end-of-input, and accepts an an bn input when the count matches, so the language is deterministic context-free. The standard strict-separation example a* union {an bn} is not an LL(k) language for any finite k: arbitrarily long common a-prefixes postpone the distinction between an unmatched all-a ending and the matching b-suffix beyond any fixed lookahead. A predictive leftmost derivation cannot use that late distinction to discharge an unbounded number of already predicted matching b obligations. This is the language-level bounded-lookahead obstruction, not merely an observation that one displayed grammar is not left-factored. Thus I and III, C.

Original paper, page 6 · Answer key