Skip to content
Mad4Study

Engineering & Science

GATE Computer Science

  • 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.

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.

  1. aa and ab are accepting (second-last symbol a); ba and bb are not.
  2. aa and ab are separated by the suffix b: aab ends in ab (second-last a, accepted) but abb ends in bb (rejected).
  3. ba and bb are separated by the suffix a: baa ends in aa (accepted) but bba ends in ba (rejected).
  4. 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

  • 33 is enough for 'ends in a', but this language needs the last two symbols.
  • 22 remembers only the last symbol.
  • 88 is 232^3, the count for the third-last symbol.

Report an error

GATE CS · Theory of Computation · Regular Languages