GATE Computer ScienceModerateGATE CS (PYQ pattern)

L = { aⁿbᵐ : n, m ≥ 0 and n ≡ m (mod 3) }. How many states does the minimal complete DFA for L have?

  1. A. 7
  2. B. 4
  3. C. 6
  4. D. 9

Correct answer: A. 7

In the a-phase remember n mod 3 (3 states); after the first b remember (n − m) mod 3 (3 states); plus a dead state for an a after a b. The a-phase state 0 (accepts ε) and b-phase state 0 also accept ε but differ on the suffix ab: from the a-phase state it gives n ≡ 1 ≡ m (accepted), from the b-phase state the a leads to the dead state, so nothing merges: 3 + 3 + 1 = 7.

More Theory of Computation questions

Exams that ask this topic