GATE Computer ScienceHardNIELIT Scientist B
Using E → E + T | T; T → T * F | F; F → ( E ) | id, how many nodes (terminal leaves included) does the parse tree of id + id * id * id + id have?
- A. 20
- B. 24
- C. 26
- D. 22
Correct answer: D. 22
There are 13 non-terminal nodes (one per reduction) and 9 terminal leaves (5 id tokens, 2 plus signs and 2 stars), totalling 22.
More Compiler Design questions
- After local common-subexpression elimination, algebraic simplification (x + 0, x 1), copy propagation and dead-code elimination, how many…
- Left factoring is applied to A → a b c | a b d | a e | f, and the shared prefixes are factored as far as possible, with new non-terminals…
- How many cells of the LL(1) parsing table of E → T E′; E′ → + T E′ | ε; T → F T′; T′ → F T′ | ε; F → ( E ) | id contain a production?…
- How many states does the canonical LR(0) collection of the augmented grammar S′ → S; S → a S b | a b have, and how many of them have a…
- For E → E + T | T; T → T F | F; F → ( E ) | id, how many LR(0) states have a conflict that is resolved by the SLR(1) FOLLOW-set check…
- How many distinct strings of length at most 6 (including the empty string) are generated by the grammar S → ( S ) | S S | ε?