- GATE CS
- 2026–27 pattern practice
- Theory of Computation
- Finite automata
- Hard
How many states does the minimal DFA have for the language of strings over {a, b} whose second-last symbol is a?
Regular Languages
Pick an option to check your answer.
Answer: C. Solution
The DFA must remember the last two symbols read: aa, ab, ba or bb. The start state behaves like bb, because no a has been seen in either of the last two positions.
- aa and ab are accepting (second-last symbol a); ba and bb are not.
- aa and ab are separated by the suffix b: aab ends in ab (second-last a, accepted) but abb ends in bb (rejected).
- ba and bb are separated by the suffix a: baa ends in aa (accepted) but bba ends in ba (rejected).
- An accepting and a rejecting state are separated by the empty suffix.
So all four states are distinguishable, and 4 states suffice.
Why not the others
- is enough for 'ends in a', but this language needs the last two symbols.
- remembers only the last symbol.
- is , the count for the third-last symbol.