GATE Computer ScienceVery hardGATE CSE

With Sethi–Ullman numbering (left leaf = 1, right leaf = 0, internal node = max(l,r) if l ≠ r else l+1), what is the label of the root of ((a+b)*(c+d)) − (((e+f)*(g+h)) / ((i+j)*(k+l)))?

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

Correct answer: D. 3

Each product (x+y)*(z+w) has label 2; the division of two products has label 3; the root has children labelled 2 and 3, so its label is max(2,3) = 3.

More Compiler Design questions

Exams that ask this topic