GATE Computer ScienceVery hardGATE CS (PYQ pattern)
How many binary strings of length 10 contain 0110 as a substring?
- A. 393
- B. 448
- C. 417
- D. 373
Correct answer: A. 393
Count the complement with a KMP automaton for 0110 (self-overlap only on '0'): the strings avoiding it number 631, so 393 contain it. The naive 7·2⁶ = 448 double-counts strings with two occurrences.
More Theory of Computation questions
- How many strings of length 7 over {a, b} belong to the language of the regular expression (a + ab + ba)?
- How many strings of length 10 over {a, b} lie in the language of the regular expression abab?
- The regular expression ((aa + bb)(ab + ba)) is over Σ = {a, b}. How many states does the minimal complete DFA for its language have?
- Exactly one of the following strings is NOT in the language of (a + ab)(b + ba). Which one?
- The regular expression a(bab)a is over Σ = {a, b}. How many states does the minimal complete DFA for its language have?
- The regular expression (a + b)(ab + ba)(a + b) is over Σ = {a, b}. How many states does the minimal complete DFA for its language have?