Power of NPDA vs DPDA
A Pushdown Automaton (PDA) is a finite automaton with a stack that provides extra
memory. The key difference between Non-deterministic PDA (NPDA) and Deterministic
PDA (DPDA) lies in their computational power.
Power of NPDA
An NPDA (Non-deterministic PDA) can recognize all Context-Free Languages (CFLs)
using non-deterministic choices and ε-moves.
Example Language Recognized by NPDA but Not by DPDA
L={wwR∣w∈{a,b}∗}(Palindrome Language – strings that read the same forward and
backward)
• An NPDA can recognize this by:
1. Guessing the middle of the string (non-deterministically).
2. Pushing the first half onto the stack.
3. Matching the second half by popping from the stack.
• A DPDA cannot recognize this because it cannot deterministically decide where
the middle is.
Thus, NPDAs can recognize more CFLs than DPDAs.
Power of DPDA
A DPDA (Deterministic PDA) can only recognize a strict subset of CFLs, known as
Deterministic Context-Free Languages (DCFLs).
Example Language Recognized by DPDA
L = { a^n b^n }
A DPDA can recognize this by:
1. Pushing aaa's onto the stack.
2. Popping an aaa for each bbb.
3. Accepting if the stack is empty at the end.
• Why can a DPDA recognize it?
o At each step, there is only one valid action, making it deterministic.
Key Comparison
Feature NPDA DPDA
Language Power All CFLs Strict subset of CFLs (DCFLs)
Determinism Non-deterministic (multiple Deterministic (one choice per
choices) step)
ε-transitions Allowed freely Restricted (must be unique)
Example L={ ww^R } (Palindrome) L = { a^n b^n }
Language
Parsing Handles ambiguous grammars Used for LL(1) parsing
Final Takeaway
L(DPDA)⊂L(NPDA)=CFL
• NPDAs are strictly more powerful than DPDAs.
• Some CFLs cannot be recognized by any DPDA (e.g., palindromes).
• Languages like a^n b^n c^n are not CFLs and require a Turing Machine or a
Two-Stack PDA.