40 40 votes Given the following expression grammar:$$\begin{align}E &\to E * F \mid F + E \mid F \\[1em]F &\to F - F \mid id\end{align}$$Which of the following is true?$*$ has higher precedence than $+$$-$ has higher precedence than $*$$+$ and $-$ have same precedence$+$ has higher precedence than $*$ Compiler Design gatecse-2000 operator-precedence normal compiler-design isro2015 ambiguous-grammar + – Kathleen 16.6k views answer comment Share Follow Print See all 3 Comments 3 3 Comments reply ruchit816 commented Jul 20, 2023 reply Follow flag the operator which is more far away from the starting symbol will always have higher precedence. 1 1 replyShare js__ commented Nov 4, 2025 reply Follow flag Operator which is at the more depth of the Tree will have Higher Precedence here , + , * have Same Precedence while - have more than both 1 1 replyShare chidambareswar23 commented Jan 28 reply Follow flag All questions related to Expression grammar: Associativity, Precedence & (Ambiguity elimination):Compiler Design: GATE CSE 1997 | Question: 1.6Compiler Design: GATE CSE 2000 | Question: 2.21, ISRO2015-24Compiler Design: GATE CSE 2014 Set 2 | Question: 17Compiler Design: GATE CSE 2016 Set 1 | Question: 45Compiler Design: GATE CSE 2024 | Set 1 | Question: 23 0 0 replyShare Please log in or register to add a comment.
Best answer 42 42 votes Correct Option: B operator which is at a lower level in the grammar is termed to have higher precedence. Gate Keeda answered Dec 8, 2014 • edited Nov 16, 2024 by Hira Thakur Gate Keeda comment Share Follow See all 7 Comments 7 7 Comments reply Show 4 previous comments Apoorva Jain commented Jan 9, 2019 reply Follow flag I think grammar is ambiguous as a-a-a can have 2 parse tree (- has no associativity) 1 1 replyShare Thadymademe commented Oct 21, 2022 reply Follow flag @Apoorva Jain you are right . The given grammar is ambigious... 2 2 replyShare Saquib001 commented Sep 2, 2025 reply Follow flag I think operator precidence from compiler desighn 0 0 replyShare Please log in or register to add a comment.
14 14 votes $F->F-E$ Operator at lower level in tree has higher precedence than operator at upper levels. $-$ has higher precedence than $+$ and $*$ $+$ and $*$ have equal precedence Correct Answer : $B$ Pooja Palod answered Dec 6, 2015 • edited Oct 30, 2025 by Umesh Shelke Pooja Palod comment Share Follow 0 reply Please log in or register to add a comment.
10 10 votes option b is right abhishekmehta4u answered Mar 23, 2019 abhishekmehta4u comment Share Follow 0 reply Please log in or register to add a comment.
3 3 votes Precedence of '$*$' $=$ Precedence of '$+$' $<$ precedence of '$-$' $<$ Precedence of $'id '$ Digvijay Pandey answered Nov 16, 2015 • edited Oct 30, 2025 by Umesh Shelke Digvijay Pandey comment Share Follow 0 reply Please log in or register to add a comment.
2 2 votes Given Grammar is:$E->E*F |F+E|F$$F->F-|id$The operators at the lower level has higher precedence than those at the higher levels.Here, $*$ and $+$ has same precedence, as they are at the same level.$-$ has higher precedence than $*$ and $+$ as it is in higher level.So, $B$ is the correct option. monanshi answered Dec 6, 2015 • edited Oct 30, 2025 by Umesh Shelke monanshi comment Share Follow 0 reply Please log in or register to add a comment.
1 1 vote Both B and D are true. Operator which is at lower level in the grammar have higher precedence.!! PRANAV M answered Aug 5, 2018 1 flag: ✌ Low quality (Aman Shukla “Wrong”) PRANAV M comment Share Follow See all 2 Comments 2 2 Comments reply anchitjindal07 commented Nov 6, 2018 reply Follow flag + is at same level as * 1 1 replyShare Gate Fever commented Nov 19, 2018 reply Follow flag am not able to construct syntax tree for 9*2+3 when i am making it, order of evaluation becomes = (9+2)*3 how to chk precedence b/w + & * now? @anchitjindal07 @PRANAV M 0 0 replyShare Please log in or register to add a comment.