GATE Computer ScienceVery hardGATE CS (PYQ pattern)

Let L = { w ∈ {a, b}* : (n_a(w) − 2·n_b(w)) mod 6 ∈ {0, 3} }, where n_a and n_b count the a's and b's. How many states does the minimal complete DFA for L have?

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

Correct answer: A. 3

A mod-6 counter (a: +1, b: −2 ≡ +4) reaches all six residues, but the accepting set {0, 3} is invariant under adding 3, so residues r and r + 3 accept exactly the same suffixes and merge. Only the residue mod 3 matters, and those 3 classes are pairwise distinguishable (append a's). Answer 3, not the naive 6.

More Theory of Computation questions

Exams that ask this topic