PDA for aⁿbᵐaⁿ

December 4, 2026 · Team EasyExamNotes · 1 min read (est.) · 0 comments

Share on WhatsApp

← RGPV CS-501 (CBGS) Theory of Computation November 2019 Solved Paper

Question

Design a PDA accepting L = {aⁿbᵐaⁿ | m,n > 0}.

Asked in: CS-501 | November 2019 | 5

Answer

Use states q₀ (push), q₁ (middle block), q₂ (pop), qf (accept), stack alphabet {Z,A}, initial stack Z. Acceptance is by final state after all input is consumed.

Transitions, written (state,input,top)→(state,replacement):
(q₀,a,Z)→(q₀,AZ)
(q₀,a,A)→(q₀,AA)
(q₀,b,A)→(q₁,A)
(q₁,b,A)→(q₁,A)
(q₁,a,A)→(q₂,ε)
(q₂,a,A)→(q₂,ε)
(q₂,ε,Z)→(qf,Z). All other transitions are undefined.

The first block pushes one A per a. At least one b is required to enter q₁. Each trailing a removes one A. Acceptance is possible exactly when the counts match and input is exhausted. For aabbaa, the stack evolves Z→AZ→AAZ→AAZ→AAZ→AZ→Z. The machine rejects abbaaa and aa because the counts or middle block fail.

PDA for aⁿbᵐaⁿ
PDA for aⁿbᵐaⁿ

← RGPV CS-501 (CBGS) Theory of Computation November 2019 Solved Paper

Discussion

Ask a question, share your thoughts or report an error.

Sign in to participate in the discussion.

Join the discussion