GATE Computer ScienceHardGATE CS (PYQ pattern)

For the grammar S → aSbb | aaSb | ε, how many distinct parse trees does a⁶b⁶ have?

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

Correct answer: A. 6

Using aSbb i times and aaSb j times yields a^(i+2j) b^(2i+j). a⁶b⁶ needs i + 2j = 6 and 2i + j = 6, so i = j = 2. The four rule applications can be ordered in any way along the single spine: C(4, 2) = 6 parse trees.

More Theory of Computation questions

Exams that ask this topic