Question: Problem 4. (a) You are given a set of n items of sizes 1, ..., An E N, and a bin of size BEN. Your

Problem 4. (a) You are given a set of n items of sizes 1, ..., An E N, and a bin of size BEN. Your goal is to find a maximum cardinality subset of items that all fit inside the bin. That is, you want to find a set of distinct indices I = {1,...,} {1,...,n}, such that + ... + SB maximizing k. For example, if the sizes are ai = 7, 42 = 4, a3 = 5, and the bin size is B = 10, then the optimum solution is I = {2,3} (that is, picking the second and the third item). Design a greedy algorithm for this problem. The running time of your algorithm should be polynomial in n. (b) Suppose that instead of maximizing k, we want to maximize the total size of the items in the bin; that is, we want to maximize the quantity size(I) = i +...+ Show that your greedy algorithm does not work in this case. Problem 4. (a) You are given a set of n items of sizes 1, ..., An E N, and a bin of size BEN. Your goal is to find a maximum cardinality subset of items that all fit inside the bin. That is, you want to find a set of distinct indices I = {1,...,} {1,...,n}, such that + ... + SB maximizing k. For example, if the sizes are ai = 7, 42 = 4, a3 = 5, and the bin size is B = 10, then the optimum solution is I = {2,3} (that is, picking the second and the third item). Design a greedy algorithm for this problem. The running time of your algorithm should be polynomial in n. (b) Suppose that instead of maximizing k, we want to maximize the total size of the items in the bin; that is, we want to maximize the quantity size(I) = i +...+ Show that your greedy algorithm does not work in this case
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
