GATE Computer ScienceHardGATE CS (PYQ pattern)
How many strings of length 10 over {a, b} contain aa as a substring but do not contain bb?
- A. 152
- B. 130
- C. 142
- D. 89
Correct answer: C. 142
Strings avoiding bb number F(12) = 144; among them only the 2 alternating strings avoid aa too. So 144 − 2 = 142.
More Theory of Computation questions
- How many strings of length exactly 9 are generated by the grammar S → aSbb | bSaa | SS | ε?
- 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?