GATE Computer ScienceModerateGATE CS · ISRO

Using E → E + T | T; T → T * F | F; F → id, how many reductions does a bottom-up parser perform for the input id + id * id?

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

Correct answer: C. 8

The parse tree has 8 internal nodes: F→id three times, T→F twice, T→T*F once, E→T once and E→E+T once, which gives 8 reductions.

More Compiler Design questions

Exams that ask this topic