GATE Computer ScienceVery hardGATE CS (PYQ pattern)

A DFA over {a, b} has states 0 to 5, transitions 0: a→4, b→2; 1: a→4, b→2; 2: a→3, b→3; 3: a→5, b→0; 4: a→0, b→5; 5: a→2, b→4. Start 0, accepting {1, 3}. How many of the 32 strings of length 5 does it accept?

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

Correct answer: A. 8

State 1 is unreachable (nothing enters it), so only state 3 matters. Count strings per state, length by length: n=1: {2:1, 4:1}; n=2: {0:1, 3:2, 5:1}; n=3: {0:2, 2:2, 4:2, 5:2}; n=4: {0:2, 2:4, 3:4, 4:4, 5:2}; n=5: {0:8, 2:4, 3:8, 4:4, 5:8}. State 3 at n = 5 is entered only from state 2, on both letters, so it holds 2·4 = 8 strings.

More Theory of Computation questions

Exams that ask this topic