GATE Computer ScienceVery hardGATE CS

A C comment is /* followed by any text that does not contain */ followed by */ . Over the alphabet { /, *, x } the language is /\*([^*]|\*+[^*/])*\*+/ . How many states does the minimal complete DFA (dead state included) for this language have?

  1. A. 5
  2. B. 6
  3. C. 7
  4. D. 8

Correct answer: B. 6

States: start; after '/'; inside the comment; inside after a '*' (possible end); the accepting state after the closing '/'; and the dead state (after any character following the accepting state, or after '/' not followed by '*'). Once inside, x and '/' return to 'inside' and '*' moves to 'after *', so there are no further states: 6.

More Compiler Design questions

Exams that ask this topic