0

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?

1 Answers1

0

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 $$

Rick Decker
  • 15,016
  • 5
  • 43
  • 54