Data Structures & AlgorithmsVery hard

How many NON-EMPTY subsequences of 2 3 4 7 8 5 (position subsets read in order) alternate in parity, so that each chosen value has the opposite parity to the one before it?

  1. A. 14
  2. B. 26
  3. C. 7
  4. D. 32

Correct answer: D. 32

Each consecutive pair in the chosen subsequence must have differing parity, which is the parity of their difference being odd. Requiring equal parity, dropping singletons, or requiring only even values each change the set.

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

Exams that ask this topic