Consider two binary operators ‘ ‘ and ‘‘ with the precedence of operator being lower than that of the operator. Operator is right associative while operator is left associative. Which one of the following represents the parse tree for expression (7 3 4 3 2)? (GATE CS 2011)
Answer: (B)
Explanation: Let us consider the given expression ().
Since the precedence of is higher, the sub-expression () will be evaluated first. In this sub-expression, would be evaluated first because is right to left associative. So the expression is evaluated as . Also, note that among the two operators, first one is evaluated before the second one because the associativity of is left to right.
Quiz of this Question
Ready to dive in? Explore our Free Demo Content and join our DSA course, trusted by over 100,000 neveropen!