Open In App

GATE | GATE-CS-2007 | Question 79

For the correct answer strings to below grammar, how many derivation trees are there?

 


(A)

1

(B)



2

(C)

3

(D)

4


Answer: (B)
Explanation:

When it asks about the no of derivations tree, we should consider either left most derivation(LMD) or right most derivations(RMD), but not both. Here two left most derivations are possible for the correct string of the previous question \”aabbab\” from the given grammar. 

LMD-1 S -> aB [Using S –> aB] -> aaBB [Using B –> aBB] -> aabB [Using B –> b] -> aabbS [Using B –> bS] -> aabbaB [Using S –> aB] -> aabbab [Using B –> b] 

LMD-2 S -> aB [Using S –> aB] -> aaBB [Using B –> aBB] -> aabSB [Using B –> bS] -> aabbAB [Using S –> bA] -> aabbaB [Using A –> a] -> aabbab [Using B –> b] The Derivation tress are shown below : 

 


Quiz of this Question
Please comment below if you find anything wrong in the above post
Article Tags :