GATE Computer ScienceVery hardGATE CS (PYQ pattern)

With instructions OP R, R and OP R, M (a leaf that is a right child can be a memory operand), the Sethi-Ullman algorithm labels a left leaf 1 and a right leaf 0, and an interior node max(l1, l2) if l1 ≠ l2, else l1 + 1. What is the least number of registers needed to evaluate (((a - b) * (c + (d * e))) + ((f * g) - (h + (i - j)))) with no spills?

  1. A. 4
  2. B. 2
  3. C. 5
  4. D. 3

Correct answer: D. 3

Bottom-up labelling gives 3 at the root.

More Compiler Design questions

Exams that ask this topic