GATE Computer ScienceVery hardGATE CS (PYQ pattern)

A DFA reads a binary number most-significant bit first (leading zeros allowed; the empty string counts as 0). How many states does the minimal complete DFA have for the multiples of 6, and for the multiples of 12?

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

Correct answer: B. 4 and 5

Track the value mod 3 and only as much of the tail as matters. For 6 the number must be ≡ 0 (mod 3) and end in 0; once the residue mod 3 is non-zero the last bit is irrelevant (more bits must come anyway), so the classes are: r = 0 ending in 0 (or empty), r = 0 ending in 1, r = 1, r = 2: 4. For 12 = 4·3 the r = 0 class splits by the tail (ends in 00 or empty, ends in a single 0, ends in 1): 3 + 2 = 5.

More Compiler Design questions

Exams that ask this topic