GATE Computer ScienceHardGATE CSE · UGC NET
Consider the grammar S → aSb | bSa | SS | ε. How many strings of length exactly 8 does it generate?
- A. 70
- B. 56
- C. 100
- D. 256
Correct answer: A. 70
The grammar generates exactly the strings with equally many a's and b's, so the count is C(8,4) = 70 (confirmed by closure enumeration).
More Theory of Computation questions
- For a Turing machine M given as input, which one of the following problems is decidable?
- Let L be the set of strings over {a, b} whose second symbol from the right is a, and which also satisfy: the last symbol is b, or the…
- Over {a, b, c}, let L = {aⁱbʲcᵏ : i = j} ∪ {aⁱbʲcᵏ : j = k} (i, j, k ≥ 0). How many strings of length at most 12 belong to L?
- Let A ≤ₘ B denote a many-one (mapping) reduction from A to B. How many of the following hold for all A, B? (i) B decidable ⇒ A decidable…
- Consider the grammar S → aSa | bSb | a | b | ε. How many strings of length exactly 7 does it generate?
- Let L = { w ∈ {a, b} : the number of a's is divisible by 4 and w contains bb as a substring }. How many states does the minimal complete…