← RGPV CS-501 Theory of Computation November 2023 Solved Paper
Question
Define ambiguous grammar and determine whether S→SS|a|b is ambiguous.
Asked in: CS-501 | November 2023 | 3(a)
Answer
The word aaa has two distinct leftmost derivations: S⇒SS⇒SSS⇒aSS⇒aaS⇒aaa (left grouping), and S⇒SS⇒aS⇒aSS⇒aaS⇒aaa (right grouping). Their trees group (aa)a and a(aa). Therefore the grammar is ambiguous. An unambiguous grammar for the same nonempty binary-alphabet language is S→aS|bS|a|b.
← RGPV CS-501 Theory of Computation November 2023 Solved Paper
Discussion
Ask a question, share your thoughts or report an error.
Sign in to participate in the discussion.
Join the discussion