The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
+23 votes

Consider two binary operators $` \uparrow '$  and $‘ \downarrow ’$ with the precedence of operator $\downarrow$ being lower than that of the operator $\uparrow$. Operator $\uparrow$ is right associative while operator $\downarrow$ is left associative. Which one of the following represents the parse tree for expression $(7 \downarrow 3 \uparrow 4 \uparrow 3 \downarrow 2)$



asked in Compiler Design by Veteran (96.1k points)
edited by | 1.8k views

3 Answers

+30 votes
Best answer

Answer is B.

To make the parse tree start compiling the identifiers into blocks based on associativity and precedence.

Grouping: $(7 \downarrow (3 \uparrow(4 \uparrow 3)))  \downarrow2 $

Tree can be made by opening inner braces and move towards braces.

answered by Active (4.2k points)
edited by
+8 votes
Higher precedence operator comes at lowest level in the tree.And and if there is left recursion on operator then it is left assosiative ,same if right recursive then it is right associative. Scince tree is given it can be easily seen.As B) is correct.
answered by Junior (599 points)
–1 vote
answer - B
answered by Loyal (8.7k points)
How B Explain In your words

Related questions

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
49,530 questions
54,139 answers
71,068 users