1.7k 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)

edited | 1.7k views

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
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.
–1 vote
0
How B Explain In your words

1
2