GATE / CS ARCHIVE

GATE CSE 2001 / QUESTION 6

Deterministic PDA for aⁿcb²ⁿ

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

GATE 2001, Q6 Descriptive
Report issue

Pushdown Automata

Question 6, GATE 2001: L={aⁿcb²ⁿ | n≥1}, alphabet {a,b,c}; specify accepting state.

Task: Construct a deterministic PDA and specify its accepting state.
Tap to enlarge
Shared context

L={aⁿcb²ⁿ | n≥1}, alphabet {a,b,c}; specify accepting state.

Answer & solution

Answer: Push two X markers per a, consume one per b after c, accept only on exhaustion of markers and input. (no official key was published)

1. Use stack alphabet {Z,X} with bottom marker Z, and states q0 (start), qA (a phase), qB (b phase), qF (sole accepting state). Stack top is written at the left. A transition (q,s,T)→(p,γ) consumes s and replaces top T by γ.

2. Define δ(q0,a,Z)=(qA,XXZ); δ(qA,a,X)=(qA,XXX); δ(qA,c,X)=(qB,X); δ(qB,b,X)=(qB,ε); δ(qB,ε,Z)=(qF,Z). All unspecified transitions reject. Accept by final state only after all input is consumed.

3. The first a is required to leave q0, enforcing n≥1. Each subsequent a replaces one X with three, a net push of two; after n a symbols there are exactly 2n markers. The unique c switches irreversibly to qB.

4. Each b pops one X. Exactly 2n b symbols expose Z, allowing the ε-move to qF. Too few leave the PDA nonaccepting; extra input cannot be consumed from qF. Wrong symbol order has no transition.

5. Determinism holds because qB has a b transition only with top X and an ε-transition only with top Z; no fixed state/top pair offers both an ε-transition and an input transition.

Original paper, page 7