GATE | GATE-CS-2007 | Question 79
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 :
Recommended Posts:
- GATE | GATE-CS-2015 (Mock Test) | Question 10
- GATE | GATE-CS-2015 (Mock Test) | Question 11
- GATE | GATE-CS-2015 (Mock Test) | Question 17
- GATE | GATE-CS-2015 (Mock Test) | Question 13
- GATE | GATE-CS-2015 (Mock Test) | Question 14
- GATE | GATE-CS-2015 (Mock Test) | Question 17
- GATE | GATE-CS-2015 (Mock Test) | Question 16
- GATE | GATE-CS-2015 (Mock Test) | Question 17
- GATE | GATE-CS-2015 (Mock Test) | Question 9
- GATE | GATE-CS-2015 (Mock Test) | Question 8
- GATE | GATE-CS-2015 (Mock Test) | Question 10
- GATE | GATE-CS-2015 (Mock Test) | Question 2
- GATE | GATE-CS-2015 (Mock Test) | Question 17
- GATE | GATE-CS-2015 (Mock Test) | Question 4
- GATE | GATE-CS-2015 (Mock Test) | Question 5