Given a list of n integers, find the minimum cardinality subset with sum greater than or equal to x
Is there a polynomial time algorithm to solve this problem?
Yes. In fact, brute force will get you your desired outcome.
- Sort the list: O(n log n)
- Start from the end with the maximum value (either end depending on how you sorted (i.e. ascending or descending order)) and add values until you have reached your goal: O(n)
Overall, this algorithm has O(n log n) complexity, which lives in polynomial time.
There probably is a better algorithm, but I'm not sure. I know one can find the nth largest value in O(n) time, however you will have to perform this m times, where m represents the minimal cardinality. Thus, for this approach, the overall complexity is O(m * n) which is still polynomial.
The first approach gives O(n log n) regardless of the size of the minimal cardinality. The second approach gives a better best case (i.e. the cardinality ends up being 1, which means the overall complexity is O(n)), however the worst case is O(n^2) which means the entire list is checked.
Can one reduce an optimization instance of subset sum into that problem?
I don't think so. Targeting a specific value for the sum is a bit different than what we are doing. For example, given a list and two different values, we would perform the exact same steps for the given problem. For each value, the only difference is when we surpass our value. For the subset sum problem, we could have vastly different outcomes for each value.