Back to the 2026 paper

Module 2: Syntax Analysis (Parser)

20262m

In bottom-up parsing, the parser constructs:
(i) Leftmost derivation
(ii) Rightmost derivation
(iii) Reverse of a rightmost derivation
(iv) Leftmost derivation in reverse

Worked SolutionAI Assisted

Answer: (iii) Reverse of a rightmost derivation

Explanation

A bottom-up (shift-reduce) parser starts from the input string and repeatedly reduces a handle to a non-terminal until the start symbol is reached.

Each reduction undoes one step of a rightmost derivation, so the sequence of reductions is a rightmost derivation traced backwards.

Example for E→E+E∣idE \to E+E \mid id on id+idid + id:

  • Rightmost derivation: E⇒E+E⇒E+id⇒id+idE \Rightarrow E+E \Rightarrow E+id \Rightarrow id+id
  • Reductions performed by the parser: id+id→E+id→E+E→Eid+id \to E+id \to E+E \to E (exactly the reverse).

(Top-down parsers build a leftmost derivation; options (i), (ii), (iv) are wrong.)

(iii) Reverse of a rightmost derivation\boxed{\text{(iii) Reverse of a rightmost derivation}}

Similar questions

Official AppAndroid App

PYQDeck for Android

Solve BEU previous-year exam papers anywhere, anytime. Fast search, offline paper viewing, and step-by-step solutions designed specifically for your phone.