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?
- A. 13
- B. 15
- C. 17
- 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
- In the Thompson NFA for (a|b), each symbol machine has 2 states and 1 non-ε edge; union and star add a new start and final state with 4…
- 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…
- A C comment is / followed by any text that does not contain / followed by / . Over the alphabet { /, , x } the language is /([^]|+[^/])+/…
- A flow graph has nodes 1 to 10, entry node 1, and edges 1→2, 2→3, 3→4, 4→5, 5→3, 4→6, 6→7, 7→2, 7→8, 8→9, 9→8, 9→10, 6→10, 3→9. A back…
- For the flow graph with entry 1 and edges 1→2, 2→3, 3→4, 4→5, 5→3, 4→6, 6→7, 7→2, 7→8, 8→9, 9→8, 9→10, 6→10, 3→9, which is the dominance…
- An expression is very busy at a point if, along every path from that point, it is evaluated before any of its operands is redefined…