GATE Computer ScienceModerateGATE CS (PYQ pattern)
The language generated by S → aSb | aSbb | ε is
- A. { aⁿbᵐ : m ≥ n }
- B. { aⁿb²ⁿ : n ≥ 0 }
- C. { aⁿbᵐ : n ≤ m ≤ 2n }
- 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
- 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?
- The following grammars all generate subsets of {a, b}, with S as the start symbol. Exactly one of the four grammars is unambiguous; which…