GATE Computer ScienceVery hardGATE CS (PYQ pattern)

L = { w ∈ {a, b}* : |w| ≥ 2 and the 2nd symbol from the left equals the 2nd symbol from the right }. How many states does the minimal complete DFA for L have?

  1. A. 8
  2. B. 9
  3. C. 16
  4. D. 11

Correct answer: D. 11

Read the first two symbols (ε, a, b: 3 classes), remember the 2nd symbol s, then track the last two symbols to know the 2nd-from-right and the next one: for each s, 4 windows (the window decides acceptance and the future). 3 + 2 × 4 = 11; nothing merges because both values of s are reachable with every window.

More Theory of Computation questions

Exams that ask this topic