Assume two binary operators '^' and 'v'. '^' has higher precedence than 'v'. Operator '^' is right associative while operator 'v' is left associative. Which…
Assume two binary operators '^' and 'v'. '^' has higher precedence than 'v'. Operator '^' is right associative while operator 'v' is left associative. Which of the following represents the expression tree for the given expression?
(9 v 3 ^ 4 v 2)
Show answerHide answer
Correct answer: (B) Root v with left child v and right child 2; the inner v has left child 9 and right child ^, whose children are 3 and 4.
Explanation
^ binds tighter, so 3 ^ 4 is grouped first: 9 v (3 ^ 4) v 2. v is left associative, so it is (9 v (3 ^ 4)) v 2: root v with left child the inner v and right child 2.