# right and left derivatives of a cfg from parse tree?

i just want to double check with what i concluded from this parse trees.

       A
/ \
/   \
B      C
/ \    / \
0   D  D   E
|   |
0   1


from the above tree i get right derivation to be

A -> C

C -> D|E

E -> 1

D -> 0

and the left derivation as

A -> B

B -> 0|D

D -> 0

i just want someone to proof check for me. and tell me if am wrong somewhere. Thanks!

The leftmost derivation in your case is $A \to BC \to 0DC \to 0DDE \to 0D0E \to 0D01$. I'll leave you to figure out the rightmost derivation.
• ohh i think i got it now. so the right derivation would be; $A \to BC \to BDE \to 0DDE \to 00DE \to 00D1$ and why didn't we drive the D first in the left most derivation 0D0E part? Mar 9 '17 at 20:16