GATE Computer ScienceVery hardGATE CS (PYQ pattern)
How many strings of length exactly 9 are generated by the grammar S → aSbb | bSaa | SS | ε?
- A. 8
- B. 40
- C. 48
- D. 32
Correct answer: B. 40
Every string factors uniquely into 'irreducible' blocks a X bb or b X aa (X generated by S). Irreducible counts: length 3: 2 (abb, baa); length 6: 2 × 2 = 4; length 9: 2 × N(6). All strings: N(3) = 2, N(6) = 4 + 2·2 = 8, N(9) = 2·8 + 2·(2·4) + 2³ = 16 + 16 + 8 = 40. (8 is the count without S → SS.)
More Theory of Computation questions
- Let L be the set of binary strings of length at least 3 whose third symbol from the right end is 1. What is the number of states in the…
- Consider I. {aⁿbᵐcⁿdᵐ | n, m ≥ 1}, II. {aⁿbᵐcᵐdⁿ | n, m ≥ 1}, III. {wwᴿ | w ∈ {a,b}}, IV. {ww | w ∈ {a,b}}. Which of these languages are…
- Which regular expression over {0,1} denotes exactly the set of strings that do not contain two consecutive 1s?
- Which of the following problems are decidable? I. Is L(G) empty for a given CFG G? II. Is L(G1) ∩ L(G2) empty for given CFGs G1 and G2?…
- Let L = { w ∈ {a, b} : (number of a's − number of b's) is divisible by 4 }. How many states does the minimal DFA for L have?
- A grammar G in Chomsky Normal Form (no ε-production) generates a string w of length 9. How many derivation steps does any derivation of w…