GATE 2018 CS – Question 48
Consider the following parse tree for the expression `a#b\$c\$d#e#f`, involving two binary operators `\$` and `#`.
Which one of the following is correct for the given parse tree?

Practise this question in The GATE Grind →
Show answer and explanation
Correct answer: (A) `\$` has higher precedence and is left associative; `#` is right associative
Explanation
In the tree, the chain of dollar operators is grouped left to right, so the dollar operator binds tighter than `#` and is left associative. The `#` operators nest to the right, so `#` is right associative.