Skip to content
Related Articles
Get the best out of our app
Open App

Related Articles

GATE | Gate IT 2005 | Question 87

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

Q 83_Part B

Consider the context-free grammar

E → E + E
E → (E * E)
E → id

where E is the starting symbol, the set of terminals is {id, (,+,),*}, and the set of non-terminals is {E}.
For the terminal string id + id + id + id, how many parse trees are possible?

(A) 5
(B) 4
(C) 3
(D) 2

Answer: (A)

Explanation: Background Required to solve the question – Parse Tree Construction.

Explanation : In order to produce the yield id + id + id + id , 
we only required 3 productions of type E → E + E  as 3 ‘+’ are 
required in the final string. This can be done in 5 ways as shown 
in the picture given below:


This explanation has been provided by Pranjul Ahuja.

Quiz of this Question

My Personal Notes arrow_drop_up
Last Updated : 28 Jun, 2021
Like Article
Save Article
Similar Reads