E -> E + E | E * E | (E) | a

Derivation for ( (a+a) * a)

Question : Show that the grammar is ambiguous by sparse tree method

Now, I have derived two derivation using left most derivation

but it results in like this 1st : ((a+a) * a) 2nd : (a * (a+a))

is this correct or the order should also be same?


1 Answer 1


You are deriving different strings. The definition of ambiguity asks for the very same string.

In this case, that they "mean the same thing" in algebra, due to the commutative law for multiplication, is completely off topic.

  • $\begingroup$ Thanks for help. Also could you tell me how to drive the second one?Or is this unambiguous grammar. $\endgroup$
    – Amir Ali
    May 19, 2018 at 23:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.