• edited by
12,080 views
48 48 votes

Consider two binary operators $\text{‘} \uparrow \text{’}$  and $\text{‘} \downarrow \text{’}$ 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)$



  1.  


  2.  


4 Answers

Best answer
64 64 votes

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.

• edited by
17 17 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.
3 3 votes

Higher precedence operators comes at the bottom

↑ has higher precedence so  $3↑4↑3$ will be evaluated first.As ↑ is left associative so $4↑3$ will be evaluated so $4↑3$ should be at last level then 

$3↑(4↑3)$

↓ i this is left associative so left operand i.e & will be evaluated 

$(7↓(3↑(4↑3))$

and then 2 

$((7↓(3↑(4↑3))↓2)$

which gives option (B)

 

0 0 votes
answer - B
Answer:
Position:
Show:

Related questions

30 30 votes
5 answers 5 answers
17.5k
17.5k views
gatecse asked Feb 14, 2018
17,547 views
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 par...
35 35 votes
1 answers 1 answer
7.3k
7.3k views
Kathleen asked Sep 15, 2014
7,268 views
Construct all the parse trees corresponding to $i + j * k$ for the grammar $E \rightarrow E+E$ $E \rightarrow E*E$ $E \rightarrow id$In this grammar, what is the pr...
76 76 votes
4 answers 4 answers
24.7k
24.7k views
go_editor asked Sep 29, 2014
24,709 views
On a non-pipelined sequential processor, a program segment, which is the part of the interrupt service routine, is given to transfer $500$ bytes from an I/O device to mem...
28 28 votes
2 answers 2 answers
11.1k
11.1k views
Kathleen asked Sep 29, 2014
11,061 views
In the following grammar$X ::= X \oplus Y \mid Y$$Y::= Z * Y \mid Z$$Z::= id $Which of the following is true?$\text{‘}\oplus\text{’}$ is left associative while $\text{‘}*...