Computer Science EngineeringHardISRO SC

For the dangling-else grammar S -> i S e S | i S | a (i = if, e = else, a = other statement), how many parse trees derive iiiaeaea?

  1. A. 4
  2. B. 3
  3. C. 2
  4. D. 6

Correct answer: B. 3

Each else may associate with any still-open if; counting derivations by span gives 3.

More Theory of Computation, Compilers & Digital Logic (ISRO CS) questions

Exams that ask this topic