← RGPV CS-501 Theory of Computation May 2023 Solved Paper
Question
Design a PDA for wwᴿ where w∈{a,b}².
Asked in: CS-501 | May 2023 | 7(ii)
Answer
The literal language is {aaaa, abba, baab, bbbb}. Push the first two symbols onto the stack, then match and pop the next two symbols in reverse order. Use states q0,q1,q2,q3,q4 and final qF; stack bottom Z.
For x∈{a,b} and stack top T∈{Z,a,b}, use q0→q1 and q1→q2 on x,T→xT. For x∈{a,b}, use q2→q3 and q3→q4 on x,x→ε. Finally q4→qF on ε,Z→Z. No other transitions exist. For abba the stack sequence is Z,aZ,baZ,aZ,Z. The machine rejects abab because the third symbol fails to match the top.
If the intended language is all even-length palindromes, use an NPDA with a push phase, an ε-transition guessing the midpoint, and a matching pop phase. Accept at the bottom marker after consuming the whole input. The literal fixed-length language is regular; the unrestricted version is context-free.

Discussion
Ask a question, share your thoughts or report an error.
Sign in to participate in the discussion.
Join the discussion