GATE Computer ScienceHardGATE CS (PYQ pattern)

How many states does the minimal complete DFA have for { w ∈ {a, b}* : w contains exactly two a's OR exactly two b's }?

  1. A. 16
  2. B. 7
  3. C. 8
  4. D. 15

Correct answer: A. 16

Each condition alone needs counts 0, 1, 2, ≥3 (4 states). In the product every pair (i, j), i, j ∈ {0, 1, 2, ≥3}, is a distinct class: they differ in how many more a's or b's lead to acceptance, and (≥3, ≥3) is the single dead state. So 4 × 4 = 16; nothing merges.

More Theory of Computation questions

Exams that ask this topic