GATE Computer ScienceHardGATE CS

A floating-point literal is defined over the symbols d (digit), '.', e and s (sign) as d⁺ ( . d⁺ )? ( e s? d⁺ )?. How many states does the minimal complete DFA (dead state included) for this pattern have?

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

Correct answer: D. 8

The states are: start; after the integer digits (accepting); after '.'; after fractional digits (accepting); after e; after the sign; after exponent digits (accepting); and the dead state. The e reached from an integer and from a fraction lead to the same state, so no more states are needed: 8.

More Compiler Design questions

Exams that ask this topic