• edited by
11,958 views
47 47 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
62 62 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

29 29 votes
5 answers 5 answers
17.2k
17.2k views
gatecse asked Feb 14, 2018
17,220 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.1k
7.1k views
Kathleen asked Sep 15, 2014
7,092 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...
75 75 votes
4 answers 4 answers
24.4k
24.4k views
go_editor asked Sep 29, 2014
24,392 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...
27 27 votes
2 answers 2 answers
10.9k
10.9k views
Kathleen asked Sep 29, 2014
10,922 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{‘}*...