Skip to content
Related Articles

Related Articles

Improve Article

GATE | GATE-CS-2007 | Question 79

  • Last Updated : 14 Sep, 2021

For the correct answer strings to above question, 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 :

derivationTree



Quiz of this Question

Attention reader! Don’t stop learning now.  Practice GATE exam well before the actual exam with the subject-wise and overall quizzes available in GATE Test Series Course.

Learn all GATE CS concepts with Free Live Classes on our youtube channel.

My Personal Notes arrow_drop_up
Recommended Articles
Page :