0
$\begingroup$

I'm new to build parse trees and I'm really unsure if I'm doing this right. So I have this example Grammar (S->Sa, S->aSa, S->a) and the word I'm parsing is simply aaaa.

My solution would look like

My Solution

Is this right and is this the only possible parse tree?

$\endgroup$
0
$\begingroup$

Your tree is correct. However, it's not the only possible one. Your tree came from the derivation $$ S\Rightarrow Sa\Rightarrow aSaa\Rightarrow aaaa $$ a different one would be from $$ S\Rightarrow aSa\Rightarrow aSaa\Rightarrow aaaa $$

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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