Data Structures & AlgorithmsModerateGATE CS · TCS NQT

How many binary strings of length 6 contain no two consecutive 1s?

  1. A. 22
  2. B. 18
  3. C. 21
  4. D. 25

Correct answer: C. 21

These counts follow the Fibonacci recurrence: f(n) = f(n-1) + f(n-2), since the string either ends in 0 or ends in 10. Counting 2^6 - 6 ignores the constraint for longer runs.

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

Exams that ask this topic