GATE Computer ScienceVery hardGATE CS (PYQ pattern)

L is the set of strings over {a, b} that contain abab as a substring but do not end with abab. How many states does the minimal complete DFA for L have?

  1. A. 8
  2. B. 9
  3. C. 10
  4. D. 5

Correct answer: B. 9

Before the first abab the DFA needs the KMP progress ε, a, ab, aba (4 states). After abab has occurred, it must still track the suffix progress towards abab to know whether the string currently ends with it: progress 0, a, ab, aba, abab, giving 5 more states (abab-ending is rejecting, the others accepting). No dead state is needed: 4 + 5 = 9.

More Compiler Design questions

Exams that ask this topic