Question

In: Advanced Math

Show that the partition problem is polynomially reducible to the decision version of the knapsack problem....

Show that the partition problem is polynomially reducible to the decision version of the knapsack problem. Please give details. This problem has been "solved" before but the answer given made no sense at all.

Solutions

Expert Solution

Here is a straightforward algorithm that takes an instance of the Simple Knapsack problem and returns an equivalent instance of the Set Partition problem:

Input: Simple Knapsack problem w1, w2, ..., wn and capacity C
Output: A Set Partition problem that's equivalent to the input Knapsack Problem.

1. set S = w1 + w2 + ... + wn

2. if (C >= S/2) set wn+1 = 2*C - S
else set wn+1 = S - 2*C

3. return Set Partition problem w1, w2, ..., wn, wn+1

We should prove that the given 0/1 Knapsack problem and the Set Partition problem produced by our algorithm are equivalent.

Proposition: Given Simple Knapsack problem w1, w2, ..., wn and capacity C, the above algorithm returns an equivalent Set Partition problem.
Proof: Let S = w1 + w2 + ... + wn. First, we'll show that if the Knapsack problem is true, so is the set partition problem. Suppose that some subset of weights fills the knapsack to capacity C. The sum of all the wieghts not in the knapsack is S - C. If C ≥ S/2 the partition problem returned by the algorithm adds weight wn+1 = 2*C - S, so adding wn+1 to the set of weights not in the knapsack gives gives a set of total weight S - C + 2C - S = C, and we have a partition into two sets of weight C. If C < S/2 the partition problem returned by the algorithm adds weight wn+1 = S - 2*C, so adding wn+1 to the set of weights in the knapsack gives a set of total weight C + S - 2C = S - C, which is equal to the set of weights not in the knapsack. Thus if the original knapsack problem can be solved, so can the returned partition problem.

Next we'll show that if the Partition Problem is true, so is the Knapsack problem. Suppose that the n+1 wieghts in the partition problem can be partitioned into two sets of equal weight. If C ≥ S/2 the partition problem returned by the algorithm adds weight wn+1 = 2*C - S, so the sum of all weights in the partition problem is S + 2C - S = 2C. Thus, both partition sets sum to C, and whichever doesn't have the weight wn+1 is a solution to the original knapsack problem. If C < S/2 the partition problem returned by the algorithm adds weight wn+1 = S - 2*C, so the sum of all weights in the partition problem is S + S - 2*C = 2*(S - C). Thus, both partition sets sum to S - C, and if we remove weight wn+1 from whichever set has it, the remaining weights sum to S - C - (S - 2*C) = C and thus provide a solution to the original knapsack problem. Thus if the returned partition problem can be solved, so can the original knapsack problem.

We can't have one problem solvable without the other one being solvable as well, so either both are solvable or neither are solvable. Thus the two problems are equivalent.

Clearly, our algorithm takes polynomial time. Thus, Simple Knapsack is polynomial time reducible to Set Partition, which means among other things that if we can solve Set Partition in polynomial time we can also solve Simple Knapsack in polynomial time.


Related Solutions

7-1 Hoare partition correctness The version of PARTITION given in this chapter is not the original...
7-1 Hoare partition correctness The version of PARTITION given in this chapter is not the original partitioning algorithm. Here is the original partition algorithm, which is due to C. A. R. Hoare: HOARE-PARTITION.A; p; r/ 1 x D AOEp 2 i D p 1 3 j D r C 1 4 while TRUE 5 repeat 6 j D j 1 7 until AOEj x 8 repeat 9 i D i C 1 10 until AOEi x 11 if i <...
The Knapsack problem is an optimization problem that asks to fill a knapsack with maximum possible...
The Knapsack problem is an optimization problem that asks to fill a knapsack with maximum possible value. Using greedy paradigm, we can solve this problem easily. Your task is the following: (a) Write the pseudo-code of a greedy solution for knapsack problem. (b) Give is the time complexity of your solution in part (a). (c) Implement part (a) in C programming language.
The Knapsack problem is an optimization problem that asks to fill a knapsack with maximum possible...
The Knapsack problem is an optimization problem that asks to fill a knapsack with maximum possible value. Using greedy paradigm, we can solve this problem easily. Your task is the following: (a) Write the pseudo-code of a greedy solution for knapsack problem. (b) Give is the time complexity of your solution in part (a). (c) Implement part (a) in C programming language.
Knapsack algorithm problem: Consider the following variation of the Knapsack problem. There are n types of...
Knapsack algorithm problem: Consider the following variation of the Knapsack problem. There are n types of items, let call them 1,2,3,4,...,n. There are exactly c_i copies of item i, and each such copy has value v_i and weight w_i. As before, the knapsack capacity is W, and the other constraint is that you can only take at most c_i copies of item i ( since no more are available). Show how to compute the optimal value that can be achieved...
How to proof that the 2-partition problem can be transformed to 3-partition problem and the time...
How to proof that the 2-partition problem can be transformed to 3-partition problem and the time complexity of the transformation (i.e. the 2-partition problem can be solved by using an algorithm that solves the 3-partition problem)
Urgent! How do you do solve a knapsack problem recursively in JAVA. for an arbitrary knapsack...
Urgent! How do you do solve a knapsack problem recursively in JAVA. for an arbitrary knapsack capacity and series of weights. Assume the weights are sorted in an array. **The arguments to the knapsack function are target weight and the array index where the remaining items start. For example if you want your knapsack to weigh exactly 20 pounds and you have five items with weights of 11,8,7,6 and 5 pounds. In this case only combination that works is 8,...
how to write a genetic algorithm for a knapsack problem .
how to write a genetic algorithm for a knapsack problem .
create a genetic algorithm for knapsack problem in c++
create a genetic algorithm for knapsack problem in c++
Prove it's correct or wrong. A particular version of PARTITION runs in logarithmic time but produces...
Prove it's correct or wrong. A particular version of PARTITION runs in logarithmic time but produces splits where all elements go to the same side of the pivot every time. QUICKSORT based on this PARTITION has the same worse-case running time as the standard version.
1. (a) Consider a modified version of the Monty Hall problem. In this version, there are...
1. (a) Consider a modified version of the Monty Hall problem. In this version, there are 8 boxes, of which 1 box contains the prize and the other 7 boxes are empty. You select one box at first. Monty, who knows where the prize is, then opens 6 of the remaining 7 boxes, all of which are shown to be empty. If Monty has a choice of which boxes to open (i.e. if the prize is in the box you...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT