GATE Computer ScienceHardGATE CS (PYQ pattern)
The numbers 19, 5, 9, 18, 10, 29, 5, 24, 10 are split into two groups (every number goes into exactly one group). What is the smallest possible absolute difference between the two group sums?
- A. 1
- B. 5
- C. 3
- D. 7
Correct answer: C. 3
The total is 129 (odd), so the difference is odd. The subset-sum DP over reachable sums shows that 64 and 65 are not reachable, while 63 and 66 are, so the best split is 63 versus 66, giving |129 − 2·63| = 3 (verified by enumeration of all subset sums).
More Algorithms questions
- A + or − sign is placed in front of each of the numbers 1, 1, 2, 3, 5, 8, 13, 21 (the two 1s are different items). In how many ways is the…
- An unbounded knapsack has capacity 47 and item types (weight, value): (5, 11), (8, 19), (9, 20), (13, 29), each available any number of…
- What is the largest sum of an increasing subsequence (strictly increasing, not necessarily contiguous) of [3, 100, 4, 5, 2, 200, 6, 7, 8…
- Two players alternately take a coin from either end of the row 20, 9, 12, 17, 1, 15, 8, 2 (the total is 84) and both play optimally to…
- A stick of length 100 must be cut at positions 20, 35, 50, 70 and 85 (in any order). Each cut costs the length of the piece being cut…
- Balloons with numbers [3, 1, 5, 8, 2, 6] are burst one at a time. Bursting a balloon with neighbours l and r (a missing neighbour counts…