Consider the context-free grammar E → E + E E → (E * E) E → id where E is the…

PYQ GATE 2005

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}.

83.1 Which of the following terminal strings has more than one parse tree when parsed according to the above grammar?

(a) id + id + id + id

(b) id + (id * (id * id))

(c) (id * (id * id)) + id

(d) ((id * id + id) * id)

83.2 For the terminal string with more than one parse tree obtained as solution to Question 83.1, how many parse trees are possible?

  1. A.

    5

  2. B.

    4

  3. C.

    3

  4. D.

    2

Attempted by 262 students.

Sign up free to check your answer

Sign up free

Explore the full course: Zero To Hero

Loading lesson…