GATE / CS ARCHIVE

GATE CSE 1996 / QUESTION 13

Complete a palindrome PDA carefully

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

GATE 1996, Q13 5 marks · Descriptive
Report issue

Pushdown Automata

Question 13, GATE 1996: A PDA with states q1,q2, alphabet {a,b}, stack alphabet {a,b,Z}, initial state q1 and stack Z accepts nonempty even palindromes by empty stack. Stack top is at the right. Given δ(q1,a,Z)={(q1,Za)}, δ(q1,b,Z)={(q1,Zb)}, δ(q2,a,a)={(q2,ε)}, δ(q2,b,b)={(q2,ε)}, δ(q2,ε,Z)={(q2,ε)}, fill the two alternatives in each of δ(q1,a,a) and δ(q1,b,b). Discuss whether the displayed list is sufficient.
Tap to enlarge
Answer & solution

Answer: δ(q1,a,a)={(q1,aa),(q2,ε)}; δ(q1,b,b)={(q1,bb),(q2,ε)}. Also require δ(q1,a,b)={(q1,ba)} and δ(q1,b,a)={(q1,ab)}. (no official key was published)

In state q1, the machine is guessing and storing the first half. On a matching input/top pair, it has two nondeterministic choices: push that input as another first-half symbol, or treat it as the first symbol of the reversed second half and pop the matching top while entering q2. Thus the displayed blanks are (q1,aa) and (q2,ε) for input a/top a, and (q1,bb) and (q2,ε) for input b/top b.

Those fillings alone do not recognize all even palindromes. The paper omits the mixed push transitions δ(q1,a,b)={(q1,ba)} and δ(q1,b,a)={(q1,ab)}. With rightmost stack top, ba means retain b and push a. For example abba requires pushing b over a; it is rejected if the missing transitions are absent. This is a defect in the printed specification, not an additional blank that can be silently filled.

With these two additional rules, q1 pushes an arbitrary nonempty first half. It switches to q2 only while reading and popping a matching character, then q2 can only pop further matching characters. Finally it removes Z by ε. Acceptance requires both empty stack and exhausted input. The first symbol must be pushed, so the empty word cannot be accepted; each push corresponds to exactly one later matched input, enforcing even length. The accepted strings are exactly wwR with nonempty w. No literal filling of just the four displayed blanks repairs the missing mixed cases.

Original paper, page 8