GATE Computer ScienceHardGATE CSE · NIELIT

How many strings of length 8 does the grammar S → aSb | bSa | SS | ε generate?

  1. A. 56
  2. B. 70
  3. C. 80
  4. D. 76

Correct answer: B. 70

This grammar generates exactly the strings with equally many a's and b's, so the count is C(8,4) = 70.

More Theory of Computation questions

Exams that ask this topic