Question: Need help with algorithms homework please. I'm really stuck. Additional explanations and graphical representations would be a huge help. Thanks l. You are given a

Need help with algorithms homework please. I'm really stuck. Additional explanations and graphical representations would be a huge help. Thanks

Need help with algorithms homework please. I'm really stuck. Additional explanations and

l. You are given a set A = {al,a2, , an} of positive integers 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, i.e., ES B. The sum of the numbers in S is 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. For example, if A = {8,2,4) and B = i then the optimal solution is the subset S (8,2) (a) Here is an algorithm for the problem for i1 to n do if T +ai B then return S Describe an input for 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) Describe an algorithm that always returns a feasible subset S whose total sum is at least half as large as the total sum of an optimal subset. Your algorithm should run in O(n log n time (c) Prove that the algorithm you described in (b) indeed has the property that it always returns a feasible subset S whose total sum is at least half as large as the total sunm of an optimal subset

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!