Discussion
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?
Answer: A
The tree shows that $ has higher precedence and is left associative; # is right associative.
Precedence: the $ operations sit below the # operations, so b$c$d is grouped first and becomes an operand of #. The operator applied first, lower in the tree, binds tighter, so $ has higher precedence.
Associativity of $: in b$c$d the lower $ joins b and c, and the upper $ joins that result with d, giving (b$c)$d, which is left associative.
Associativity of #: the tree reads a # ((b$c$d) # (e#f)), so each # takes everything to its right as its right operand. That is right associative. The options giving # the higher precedence, or calling # left associative, contradict the tree.
Post your comment
Please log in or register to post a comment.
Examination Categories
- SSC Exams
- Banking Exams
- Teaching Exams
- Civil Services Exams
- Railways Exams
- Engineering Recruitment Exams
- Defence Exams
- State Government Exams
- Police Exams
- Insurance Exams
- Nursing Exams
- Other Government Exams
- NRA CET
- PG Entrance Exams
- Campus Placement
- MBA Entrance Exams
- CUET and UG Entrance
- Judiciary Exams
- Regulatory Body Exams
- Software Development