retagged by
389 views

2 Answers

5 votes
5 votes

to derive a^b*c

first we use E->E^E

then        E->E*E

then        E->id

so it print first all id , then * after this ^ will be print.

3 votes
3 votes

To derive a^b*c, one can use either of the following two derivations:-

Derivation 1:

E ==> E ^ E

   ==> E ^ E * E

   ==> a ^ b * c

Derivation 2:

E ==> E * E

   ==> E ^ E * E

   ==> a ^ b * c

Draw a parse tree for both the derivations and do a postorder traversal of the same. The outputs would be a b ^ c* and a b c * ^. Only one of these is mentioned in the option and so that would be the answer. :)

Related questions