GATE Computer ScienceVery hardGATE CS (PYQ pattern)

How many binary strings of length 10 contain 0110 as a substring?

  1. A. 393
  2. B. 448
  3. C. 417
  4. 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

Exams that ask this topic