GATE Computer ScienceModerateGATE CS (PYQ pattern)

The language generated by S → aSb | aSbb | ε is

  1. A. { aⁿbᵐ : m ≥ n }
  2. B. { aⁿb²ⁿ : n ≥ 0 }
  3. C. { aⁿbᵐ : n ≤ m ≤ 2n }
  4. D. { aⁿbᵐ : n ≤ m ≤ 2n + 1 }

Correct answer: C. { aⁿbᵐ : n ≤ m ≤ 2n }

Each application of the recursive rules adds one a and one or two b's, so with n applications m ranges over n..2n. Allowing 2n+1 or only 2n are wrong.

More Theory of Computation questions

Exams that ask this topic