GATE Computer ScienceModerateGATE CS (PYQ pattern)

How many states does the minimal complete DFA have for { w ∈ {a, b}* : |w| is divisible by 3 and the second-last symbol of w is a }?

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

Correct answer: D. 5

Only the symbol read at a length ≡ 2 (mod 3) position matters. States: length ≡ 0 non-accepting (start), ≡ 1, ≡ 2 with last symbol a, ≡ 2 with last symbol b, and ≡ 0 accepting. The two ≡ 0 states differ only on ε. 5 states, not 3 × 2 = 6.

More Theory of Computation questions

Exams that ask this topic