🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: CFG and PDA: all 10 questions

Quiz: CFG and PDA · Question 2 of 10

How many parse trees did the ambiguous grammar E → E+E | EE | id give for id+idid?

How many parse trees did the ambiguous grammar E → E+E | EE | id give for id+idid?

  1. A.1
  2. B.2
  3. C.3
  4. D.5
Answer & explanation

Correct answer: 2

(id+id)id and id+(idid) — two groupings, so it is ambiguous.

Can you get the rest right without peeking?

Take the timed Quiz: CFG and PDA quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →