GATE / CS ARCHIVE

GATE CSE 2007 / QUESTION 30

Equal blocks separated by a marker

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

GATE 2007, Q30 2 marks · MCQ
Report issue

Pushdown Automata

Question 30, GATE 2007: Classify L={0^i 2 1^i:i≥0} over alphabet {0,1,2}.
Options:
(A) Not recursive
(B) Recursive and deterministic context-free
(C) Regular
(D) Context-free but not deterministic context-free
Tap to enlarge
Your answer
Answer & solution

Answer: B (no official key was published)

1. Approach. The marker 2 identifies exactly when to switch from pushing zeros to matching ones. Unlike an unmarked palindrome, there is no need to guess the midpoint.

2. Derivation and interpretation. A deterministic PDA pushes for each initial 0, switches phase at the unique marker 2, and pops once per 1, accepting exactly when the counts match and input ends. Membership is also decidable. The language is not regular because matching unbounded block lengths requires memory. Hence it is recursive and deterministic context-free, B, including the string 2 for i=0.

Original paper, page 7