Data Structures & AlgorithmsVery hard

What is the smallest positive integer that is NOT the sum of any CONTIGUOUS (adjacent) block of [1, 2, 4, 8]?

  1. A. 16
  2. B. 5
  3. C. 6
  4. D. 4

Correct answer: B. 5

Contiguous block sums are a much smaller family than subset sums: the set {1,2,4,8} reaches every subset sum up to 15, but not every value is a block sum. Using subset sums instead of block sums gives a larger answer.

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

Exams that ask this topic