GATE Computer ScienceHardGATE CS

The Thompson construction (Aho–Sethi–Ullman style: a symbol gets 2 states; union and star each add a new start and a new final state; concatenation merges the final state of the first machine with the start state of the second) is applied to the regular expression ((a|b)c)*(a|bb). How many states does the resulting NFA have?

  1. A. 13
  2. B. 15
  3. C. 17
  4. D. 19

Correct answer: B. 15

(a|b): 2 + 2 + 2 = 6 states; concatenating c (2 states, 1 merged): 7; star: 9. a|bb: bb is 2 + 2 − 1 = 3 states, union with a gives 2 + 3 + 2 = 7. Final concatenation: 9 + 7 − 1 = 15.

More Compiler Design questions

Exams that ask this topic