← RGPV CS-501 Theory of Computation December 2025 Solved Question Paper
Question
Design a PDA for L={aⁿbⁿ | n≥1}.
Asked in: CS-501 | December 2025 | 6(b)
Answer
Use states p (push), r (pop), f (accept), stack alphabet {A,Z}, initial stack Z and initial state p. The stack top is written on the left. Acceptance is by final state after all input is consumed.
| State | Input | Top | Next | Replacement |
|---|---|---|---|---|
| p | a | Z | p | AZ |
| p | a | A | p | AA |
| p | b | A | r | ε |
| r | b | A | r | ε |
| r | ε | Z | f | Z |
All other moves are undefined. For aabb, configurations (state, remaining input, stack) are (p,aabb,Z) ⇒ (p,abb,AZ) ⇒ (p,bb,AAZ) ⇒ (r,b,AZ) ⇒ (r,ε,Z) ⇒ (f,ε,Z).
Each a adds one marker and each b removes one. The first b switches permanently to the pop phase, preventing an a after b. The final transition requires the bottom symbol, ensuring equal counts. No move accepts ε from p, so n≥1. Extra b symbols cannot be consumed after the stack returns to Z; too few b symbols leave markers. Hence exactly the required language is accepted.

← RGPV CS-501 Theory of Computation December 2025 Solved Question Paper
Discussion
Ask a question, share your thoughts or report an error.
Sign in to participate in the discussion.
Join the discussion