GATE Computer ScienceVery hardGATE CSE

Grammar: S → a S b | S S | ε. How many distinct strings of length exactly 10 belong to the language it generates?

  1. A. 252
  2. B. 32
  3. C. 42
  4. D. 52

Correct answer: C. 42

The language is the set of balanced a/b strings (a = opening, b = closing); length 10 has C₅ = 42 of them, whereas C(10,5) = 252 counts all strings with equal numbers.

More Compiler Design questions

Exams that ask this topic