The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
x
+21 votes
1.4k views

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)$

(A)

(B) 

(C) 

(D)

asked in Compiler Design by Veteran (103k points)
edited by | 1.4k views

3 Answers

+28 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
+4 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 (589 points)
–1 vote
answer - B
answered by Loyal (9k points)
0
How B Explain In your words


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

40,845 questions
47,506 answers
145,764 comments
62,261 users