GATE Computer ScienceHardGATE CS (PYQ pattern)
How many binary strings of length 12 contain neither 000 nor 111 as a substring?
- A. 466
- B. 288
- C. 754
- D. 1705
Correct answer: A. 466
Strings whose runs all have length 1 or 2 are counted by f(n) = f(n−1) + f(n−2) for each starting bit, so the total is 2·F(n+1); for n = 12 that is 2·233 = 466. Forbidding only 000 would give 1705.
More Theory of Computation questions
- How many strings of length 8 over {a, b} contain aba as a substring but do NOT contain bab?
- How many strings of length 8 over {a, b, c} have no two adjacent equal symbols and also have first symbol ≠ last symbol?
- How many binary strings of length 10 contain no two consecutive 1s and also do not have 1 at both the first and the last position?
- How many strings of length 9 over {a, b} satisfy (na − nb) ≡ 0 (mod 3) AND contain no bb as a substring?
- How many binary strings of length 10 contain 0110 as a substring?
- How many strings of length 7 over {a, b} belong to the language of the regular expression (a + ab + ba)?