GATE Computer ScienceVery hardGATE CS (PYQ pattern)

L = { w ∈ {a, b}* : (n_a(w) − n_b(w)) ≡ 0 (mod 3) and |w| is even }. How many states does the minimal complete DFA for L have?

  1. A. 18
  2. B. 12
  3. C. 6
  4. D. 3

Correct answer: C. 6

|w| = n_a + n_b ≡ n_a − n_b (mod 2), so '|w| even' just says the difference is even. Together the conditions say n_a − n_b ≡ 0 (mod 6). The DFA is a mod-6 counter (a: +1, b: −1) with one accepting residue, and all 6 residues are distinguishable: 6 states, not the 3 × 2 product counted twice or the 18 of three separate counters.

More Theory of Computation questions

Exams that ask this topic