Data Structures & AlgorithmsVery hardGATE CS · TCS NQT

How many binary strings of length 9 contain exactly 4 ones and no run of three or more consecutive 0s?

  1. A. 56
  2. B. 51
  3. C. 10
  4. D. 126

Correct answer: B. 51

Place the four ones and count the gaps of zeros between them (there are five gaps, each holding 0, 1 or 2 zeros), summing the ways for total zeros 5. Ignoring the run restriction gives the plain binomial C(9, 4) = 126.

More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions

Exams that ask this topic