4.3Deterministic vs nondeterministic PDAs
The idea
Deterministic PDAs are weaker than nondeterministic ones: palindromes need the PDA to guess the middle.
Think of it like this: Folding a string in half to check it reads the same backwards, without knowing where the middle is.
Why it exists
It separates DCFL from CFL and decides which languages have deterministic parsers.
How it works
- aⁿbⁿ, wcwᴿ and balanced brackets are deterministic.
- wwᴿ is context-free but not deterministic (the middle is unknown).
- DCFLs are closed under complement but not under union, intersection or reversal.
- Every DCFL has an unambiguous grammar.
Worked example: abba as w wᴿ
The PDA pushes a, b, then guesses the middle and pops b, a. For abab every guess fails: rejected.
Now play with it
- →Run
abbaand thenababon the palindrome PDA. - →Read the note under the widget about nondeterminism.
Moves (state, input, pop → state, push):
input: abba
- Start in q0 with stack Z
- δ(q0, a, Z) → (q0, AZ)
- δ(q0, b, A) → (q0, BA)
- δ(q0, ε, B) → (q1, B)
- δ(q1, b, B) → (q1, ε)
- δ(q1, a, A) → (q1, ε)
- δ(q1, ε, Z) → (q2, Z)
- ACCEPT: all input read and the PDA is in a final state
Top of stack is at the top of the box. Palindromes need NONDETERMINISM: the PDA must guess where the middle is.
Check yourself
Which language is accepted by a DPDA?
Exam notes (the dense version)
DCFL ⊊ CFL. aⁿbⁿ and wcwᴿ are deterministic; wwᴿ (palindromes) needs nondeterminism to guess the middle. DCFLs are closed under complement but not under union, intersection or reversal. Every DCFL has an unambiguous grammar.
Previous year questions: Pushdown Automata (2)
PYQs are grouped by topic, so this is the full set for Pushdown Automata; try the ones that match this subtopic. Open all 2 on the topic page.