GATE Computer ScienceVery hardGATE CS (PYQ pattern)

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

  1. A. 4
  2. B. 6
  3. C. 5
  4. D. 7

Correct answer: C. 5

States: ε; then (first = a, last = a), (first = a, last = b), (first = b, last = b), (first = b, last = a). Single-symbol strings merge with the equal-ends states, so there are 5 in total.

More Theory of Computation questions

Exams that ask this topic