ProgrammingVery hardGATE CS · Campus placements

How many subsets of {1, 2, 3, 4, 5, 6} have an element sum equal to 7?

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

Correct answer: B. 4

The subsets are {1,6}, {2,5}, {3,4} and {1,2,4}, which gives 4. Enumerating by bitmask with 2^6 = 64 candidates confirms this.

More C Programming questions

Exams that ask this topic