Suppose you are given a set of positive integers A = {a1, a2,...,an} and a positive integer B. A subset S c A is called feasible if the sum of the numbers in S does not exceed B:
![]()
The sum of the numbers in S will be called the total sum of S.
You would like to select a feasible subset S of A whose total sum is as large as possible.
Example. If A = {8,2,4} and B = 11, then the optimal solution is the subset S = {8,2}.
(a) Here is an algorithm for this problem.

Give an instance in which the total sum of the set S returned by this algorithm is less than half the total sum of some other feasible subset of A.
(b) Give a polynomial-time approximation algorithm for this problem with the following guarantee: It returns a feasible set S c A whose total sum is at least half as large as the maximum total sum of any feasible set S ⊆ A. Your algorithm should have a running time of at most O(n log n).
We need at least 10 more requests to produce the solution.
0 / 10 have requested this problem solution
The more requests, the faster the answer.