2 2 votes Consider the language $L$ of arithmetic expressions over the alphabet $\{i d,+, *,()$,$\} , where id$ represents any identifier or number. An example string in the language is id * (id + id) .Which of the following Context-Free Grammars that generate $L$ is ambiguous? $\begin{aligned}& E \rightarrow E+T \mid T \\& T \rightarrow T * F \mid F \\& F \rightarrow(E) \mid i d\end{aligned}$ $\begin{aligned}& E \rightarrow T E^{\prime} \\& E^{\prime} \rightarrow+T E^{\prime} \mid \epsilon \\& T \rightarrow F T^{\prime} \\& T^{\prime} \rightarrow * F T^{\prime} \mid \epsilon \\& F \rightarrow(E) \mid i d\end{aligned}$ $E \rightarrow E+E|E * E|(E) \mid i d$ $E \rightarrow E+i d|E * i d| i d$ Theory of Computation goclasses theory-of-computation goclasses-cs-dpp goclasses-cs-dpp-day-107 goclasses-toc-practice-questions + – GO Classes 501 views answer comment Share Follow Print 0 reply Please log in or register to add a comment.
2 2 votes C is ambigious A is removing ambiguity by giving preference to * over + as per bodmas rule and made them left associativityB.we removed left recursion and made into right recursion whole grammar and priorities as per bodmas rule we do to parse for LL1D.it is unambigious for given string but remember it doesnot generate all arithmetic expressions try arithmetic expression including bracket and it will fail jacknroll answered Dec 4, 2025 jacknroll comment Share Follow 0 reply Please log in or register to add a comment.
1 1 vote GO Classes answered Oct 13, 2025 1 flag: ✌ Low quality (Mihir27 “nonsense example”) GO Classes comment Share Follow See 1 comment 1 1 comment reply Pankaj_Mishra commented Jan 12 reply Follow flag What i think is when it is explicitly said in the question (id+id) then why in the solution you're trying to generate id*id+id. How and Why does the paranthesis given in the original doesn't matter here ? 0 0 replyShare Please log in or register to add a comment.
0 0 votes c example :- id*id+id derives two different parse trees so its ambiguous js__ answered Oct 15, 2025 js__ comment Share Follow 0 reply Please log in or register to add a comment.