-
Consider two binary operators ↑ and ↓ with the precedence of operator ↓ being lower than that of 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)?
-
-
-
-
- None of these
-
Correct Option: B
Let us consider the given expression (7 ↓ 3 ↑ 4 ↑ 3 ↓ 2). Since the precedence of ↑ is higher, the subexpression (3 ↑ 4 ↑ 3) will be evaluated first. In this subexpression, 4 ↑
3 would be evaluated first because ↑ is right to left associative. So the expression is evaluated
as ((7 ↓ (3 ↑ (4 ↑ 3))) ↓ 2). Also, note that among the two ¯ operators, first one is evaluated before the second one because the associativity of ↓ is left to right.