Data Structures & AlgorithmsVery hardGATE CS · CAT · MBA placement

How many binary strings of length 8 contain no two adjacent 1s and an EVEN number of 0s?

  1. A. 30
  2. B. 26
  3. C. 27
  4. D. 34

Correct answer: C. 27

Count no-adjacent-1 strings with a DP that tracks the parity of zeros as a second state. Ignoring the parity gives the Fibonacci count 55 for n = 8, which is larger than the parity-restricted count.

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

Exams that ask this topic