GATE / CS ARCHIVE

SIMILAR QUESTIONS / THEORY OF COMPUTATION

Distinguish marked and unmarked palindrome stacks

3 questions solved the same way, newest first. Back to Theory of Computation

How these are solved

An explicit middle marker makes the push-to-pop switch deterministic; without it a midpoint guess is needed. Distinguish reversal from same-order copying.

2 marks · MCQ
Report issue

Pushdown Automata

Question 36, GATE 2014: Over Σ={0,1,c}, define L1={0ⁿ1ⁿ:n≥0}, L2={wcwʳ:w∈{0,1}*}, L3={wwʳ:w∈{0,1}*}, with wʳ the reversal of w. Which languages are deterministic context-free? A none; B only L1; C only L1,L2; D all three.
Tap to enlarge
Your answer
Answer & solution

Official answer: C

Step 1: For L1, a deterministic pushdown automaton pushes one marker per 0 and switches to popping when the first 1 appears. The input symbol change identifies the phase boundary; accept when the counts match. Step 2: For L2, push the first binary word, then the marker c deterministically signals the switch to matching and popping its reverse. Step 3: In L3 there is no midpoint marker. An arbitrary binary even palindrome requires a nondeterministic choice of when to switch, and this unmarked palindrome language is a standard CFL that is not deterministic context-free. Therefore C. The final claim is the known non-DCFL result, not a claim that every language with an unmarked midpoint is automatically nondeterministic.

Original paper, page 61 · Answer key

2 marks · MCQ
Report issue

Marked palindromes versus copying

Pushdown Automata

Question 57, GATE 2005: For binary w, L1={wwᴿ}, L2={w#wᴿ} with special delimiter#, L3={ww}. Which is true? A L1 deterministic CFL; B L2 deterministic CFL; C L3 CFL but not deterministic; D L3 deterministic CFL.
Tap to enlarge
Your answer
Answer & solution

Answer: B (no official key was published)

For L2={w#wR}, a DPDA pushes before # and then deterministically pops and compares after #; it accepts exactly upon a complete match. L1={wwR} has no delimiter and is context-free but not deterministic context-free. L3={ww} is not context-free. Therefore B.

For the delimited language, # tells the PDA exactly when to switch from pushing to comparing/popping. Every decision is determined by current input and stack top, so the recognizer is deterministic. Without the delimiter, a palindrome PDA must in general choose the midpoint nondeterministically. The duplicated-word language requires preserving the same order twice, not the reverse stack order, and is not CFL. These distinctions are about whole language classes, not whether some individual examples can be recognized.

Original paper, page 7

2 marks · MCQ
Report issue

Deterministic recognition with a middle marker

Pushdown Automata

Question 6.6, GATE 1997: Which language is deterministic context-free: {wcwR:w∈{a, b}*}, unmarked even palindromes over{a, b, c}, {a^n b^n c^n}, or all palindromes over{a, b, c}?
Question 6.6, GATE 1997: Which language is deterministic context-free: {wcwR:w∈{a, b}*}, unmarked even palindromes over{a, b, c}, {a^n b^n c^n}, or all palindromes over{a, b, c}?
Tap to enlarge
Your answer
Answer & solution

Answer: A (no official key was published)

For A, the symbol c uniquely marks the midpoint because w uses only a, b. A DPDA pushes symbols before c, then deterministically switches to popping and comparing symbols after c, accepting when they match exactly and input ends. Unmarked palindrome languages require finding an unspecified midpoint and are not deterministic context-free over a multi-symbol alphabet. The equal-three-block language is not even context-free. Hence A. The delimiter’s exclusion from w is essential; without it, the same deterministic switch is unavailable.

Original paper, page 5