GATE Computer ScienceHardGATE CS (PYQ pattern)
For the grammar S → aSbb | aaSb | ε, how many distinct parse trees does a⁶b⁶ have?
- A. 6
- B. 1
- C. 2
- 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
- The language generated by S → aSb | aSbb | ε is
- The grammar S → aSb | Sb | b generates { aⁿbᵐ : m > n ≥ 0 }. How many distinct parse trees does the string aabbbb have?
- The language generated by S → aSb | bSa | SS | ε is
- The language generated by S → aSbS | ε is
- The language generated by S → TT, T → aTb | ε is
- How many strings of length at most 6 are generated by S → aSa | bSb | aa | b?