GATE Computer ScienceHardGATE CS (PYQ pattern)

A DFA over {a, b} has states 0 to 5, transitions 0: a→2, b→1; 1: a→5, b→4; 2: a→5, b→4; 3: a→3, b→0; 4: a→0, b→3; 5: a→5, b→1. Start 0, accepting {1,3}. How many strings of length at most 5 over {a, b} does it accept (counting the empty string if accepted)?

  1. A. 30
  2. B. 14
  3. C. 63
  4. D. 21

Correct answer: D. 21

Count accepted strings for each length 0..5 by dynamic programming over the transition table and add them: 21.

More Theory of Computation questions

Exams that ask this topic