GATE Computer ScienceModerateGATE CS (PYQ pattern)
How many strings of length 8 over {a, b} begin with b and contain no aa as a substring?
- A. 21
- B. 55
- C. 34
- D. 64
Correct answer: C. 34
Let f(n) be the number of strings of length n with no aa: f(1) = 2, f(2) = 3, f(n) = f(n−1) + f(n−2), so f(7) = 34. A string starting with b is b followed by any aa-free string of length 7 (the leading b cannot create aa), giving f(7) = 34.
More Theory of Computation questions
- Over Σ = {a, b, c}, how many strings of length 6 have an even number of a's and do not contain cc?
- Let L = { aⁿ : n = 1, or n ≥ 3 and (n ≡ 2 (mod 4) or n ≡ 3 (mod 6)) }. How many states does the minimal DFA for this unary language have?
- Let L = { aⁿ : n² ≡ 1 (mod 8) }. How many states does the minimal DFA for L have?
- Let L = { aⁿ : n ≥ 5 and n ≡ 1 (mod 3) }. How many states does the minimal DFA for the concatenation L·L have?
- Let L = { w ∈ {a, b} : |w| ≥ 5 and the 5th symbol from the LEFT equals the 1st symbol }. How many states does the minimal complete DFA for…
- L = { aⁿbᵐ : n, m ≥ 0 and n ≡ m (mod 3) }. How many states does the minimal complete DFA for L have?