Data Structures & AlgorithmsModerate

How many subsets of {1, 2, 3, 4, 5, 6, 7, 8} have sum exactly 15? (The empty set is excluded, and each value is used at most once.)

  1. A. 95
  2. B. 13
  3. C. 6
  4. D. 146

Correct answer: B. 13

A 0/1 subset-sum count enumerates which elements are used, each at most once. Counting sums up to 15, fixing the size to 3, or allowing repeats (unbounded multisets) each answers a different question.

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

Exams that ask this topic