GATE Computer ScienceVery hardGATE CS

Let L = { w ∈ {a, b}* : (number of a's − number of b's) is divisible by 4 }. How many states does the minimal DFA for L have?

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

Correct answer: B. 4

Only the value (#a − #b) mod 4 matters: a adds 1 and b subtracts 1. All four residues are reachable and pairwise distinguishable (append aᵏ), so the minimal DFA has 4 states, not 16.

More Theory of Computation questions

Exams that ask this topic