Question: items = { 9 . 3 , 2 4 , 1 4 , 5 , 8 , 1 7 , 4 . 2 } k
items k EXAMPLE USAGE :
We study a knapsack problem, defined as follows: Given as input a knapsack of size
and
items whose sizes are dots, where and dots, are all positive real numbers,
the problem is to find a full "packing" of the knapsack ie choose a subset of the items
such that the total sum of the sizes of the items in the chosen subset is exactly equal to
It is well known that the knapsack problem is NPcomplete, which implies that it is very likely
that efficient algorithms ie those with polynomial runtime for this problem do not exist.
Thus, people tend to look for good approximation algorithms for solving this problem. In
this exercise, we relax the constraint of the knapsack problem as follows.
We still seek a packing of the knapsack, but we need not look for a "full" packing of the
knapsack; instead, we look for a packing of the knapsack ie a subset of the input items
such that the total sum of the sizes of the items in the chosen subset is at least but no
more than This is called a factor of approximate solution for the knapsack problem.
To simplify the problem, we assume that a factor of approximate solution for the knapsack
problem always exists, ie there always exists a subset of items whose total size is at least
and at most
For example, if the sizes of the items are and then is a
factor of approximate solution. Note that such a solution may not be unique. For example,
is also a solution. Also note that the item sizes may not be integers but are positive
real numbers although they are integers in this example.
Design a polynomial time algorithm for computing a factor of approximate solution, and
analyze the running time of your algorithm using the bigWe study a knapsack problem, defined as follows: Given as input a knapsack of size K and n items whose sizes are ki k kn where K and kj ka kn are all positive real numbers, the problem is to find a full "packing" of the knapsack ie choose a subset of the n items such that the total sum of the sizes of the items in the chosen subset is exactly equal to K It is well known that the knapsack problem is NPcomplete, which implies that it is very likely that efficient algorithms ie those with polynomial runtime for this problem do not exist. Thus, people tend to look for good approximation algorithms for solving this problem. In this exercise, we relax the constraint of the knapsack problem as follows. We still seek a packing of the knapsack, but we need not look for a "full" packing of the knapsack; instead, we look for a packing of the knapsack ie a subset of the n input items such that the total sum of the sizes of the items in the chosen subset is at least Kbut no more than K This is called a factor of approrimate solution for the knapsack problem. To simplify the problem, we assume that a factor of approximate solution for the knapsack problem always exists, ie there always exists a subset of items whose total size is at least K and at most K For example, if the sizes of the n items are and K then is a factor of approximate solution. Note that such a solution may not be unique. For example, is also a solution. Also note that the item sizes may not be integers but are positive real numbers although they are integers in this example. Design a polynomial time algorithm for computing a factor of approximate solution, and analyze the running time of your algorithm using the bigO notation Note that although there may be multiple solutions, your algorithm only needs to find one solution. If your algorithm runs in On time and is correct, then you will get bonus points. Note: I would like to emphasize the following, which applies to the algorithm design questions in all assignments in this semester. Algorithm Description You are required to clearly describe the main idea of your al gorithm. Pseudocode The pseudocode is usually very helpful for explaining the algorithm. So you are strongly encouraged to provide pseudocode for your algorithm. Correctness You also need to explain why your algorithm is correct. For instance, for this knapsack problem you need to explain why your algorithm can produce a factor of approximate solution. Time Analysis You are required to analyze the running time of your algorithm.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
