Question: ( 3 0 ) ( a ) Let P 1 , P 2 , dots, P n be a set of n programs that are

(30)(a) Let P1,P2,dots,Pn be a set of n programs that are to be stored on a memory chip of capacity L. Program Pi requires ai amount of space. Note that L and ai's are all integers. We assume that a1+a2+dots+an>L. The problem is to select a maximum subset Q of the programs for storage on the chip. A maximum subset is one with the maximum number of programs in it. Give a greedy algorithm that always finds a maximum subset Q such that PiinQ?aiL. You also have to prove that your algorithm always finds an optimal solution. Note that a program is either stored on the chip or not stored at all (in other words, you do not store part of a program).
(b) Suppose that the objective now is to determine a subset of programs that maximizes the amount of space used, that is, minimizes the amount of unused space. One greedy approach for this case is as follows: As long as there is space left, always pick the largest remaining program that can fit into the space. Prove or disprove that this greedy strategy yields an optimal solution.
(c) We can formulate the problem in (b) into a decision problem as follows: given n programs of sizes a1,a2,dots,an, with chip capacity L, and integer k, is there a packing of programs onto the chip such that the unused space is k or less. Show that this decision problem is NP-complete.
 (30)(a) Let P1,P2,dots,Pn be a set of n programs that are

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!