GATE Computer ScienceVery hardGATE CS (PYQ pattern)

L1 is the set of strings over {a, b} whose third symbol from the right is a; its minimal DFA has 8 states. L2 = L1 ∩ {strings of even length}. How many states does the minimal complete DFA for L2 have?

  1. A. 16
  2. B. 8
  3. C. 12
  4. D. 6

Correct answer: D. 6

The product construction gives 16 states, but most of the window is wasted. For an even-length prefix w, any continuation must also have even length: a continuation of length 2 needs the last symbol of w to be a, and the empty continuation needs w's third-from-last symbol; for an odd-length prefix only its last two symbols matter, and only its second-last for a 1-symbol continuation. Distinguishing what really matters leaves 6 Myhill–Nerode classes (checked by enumerating all prefixes and suffixes up to length 10).

More Compiler Design questions

Exams that ask this topic