ProgrammingVery hardGATE CS · Campus placements
How many subsets of {1, 2, 3, 4, 5, 6} have an element sum equal to 7?
- A. 3
- B. 4
- C. 5
- 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
- In a 3 x 3 grid, a walker can move only right or down from the top-left corner to the bottom-right corner. How many distinct paths exist?
- T(0) = 0 and T(n) = T(n-1) + n for n >= 1. What is T(10)?
- What is gcd(48, 180) by Euclid's recursion?
- What is lcm(12, 18)?
- unsigned int u = 3; int s = -4; printf("%d", (int)u + s); What is printed?
- How many leading zero bits does the 16-bit unsigned value 0x0100 have?