GATE Computer ScienceVery hardGATE CS (PYQ pattern)

A DFA reads ternary numerals over {0, 1, 2}, most significant digit first (leading zeros allowed; ε has value 0 and is accepted), and accepts iff the value is divisible by 6. How many states does the minimal DFA have?

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

Correct answer: C. 3

Value ≡ 0 (mod 6) ⇔ divisible by 3 (last digit is 0, or ε) and even (3 ≡ 1 mod 2, so the parity of the value equals the parity of the digit sum). A state needs (parity, last digit is 0?); but once the parity is odd the last digit no longer matters for any future, so odd/0 and odd/non-0 merge. States: even & last 0 (accepting, start), even & last ≠ 0, odd — 3 states, not the 6 of a mod-6 counter.

More Theory of Computation questions

Exams that ask this topic