Question

Show that the decision version of the knapsack problem is NP-complete. (Hint: In your reduction, make...

Show that the decision version of the knapsack problem is NP-complete. (Hint: In your reduction, make use of the partition problem: given n positive integers, partition them into two disjoint subsets with the same sum of their elements. The partition problem is NP-complete.)

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Knapsack problem:

Knapsack is a problem in which we have two fileds. The given area is called knapsack given object. The main theme is to fill the knapsack area completely by getting a maximum profit. The mathematical representation of the knapsack is as follows:

Maximize    subjected to    where   

Here m represents the capacity of the knapsack to be fillled, is the profit we can earn by considering the object i, is the weight if the object i.

If =0 the object is not consider for knapsack. If =1 the entire object is consider for filling the knapsack.

In dynsmic programming either we use the object completely or ignoring them.We implement the problem by using principle of optimality. The mathematical representation of 0/1 knapsack problem is as follows:

Maximize    subjected to where

The main problem of greedy method for knapsack is where we consider partially only some of the objects that are used to fill the knapsack. Where as in dynamic pogramming the object is either completely filled or completely ignored.

Procedure:

The notations used in knapsack problem are as follows:
1. be the optimal solution, here y is the knapsack capacity,this is an optimal solotion for filling the knapsack by considering the object from i to j.

2. it is a pair of   where  , , the initial value . We can compute from .

3.We can generate the sequence of decision in order to get the optimal solution. Let   be the optimal sequence

  • If is the suitable, we consider the object otherwise the solution is from remaining set.
  • Let be the optimal solution then  

By using this we can compute the next sequence that is., to .

In this method we have two rules

1.purging rule

2.discarding or searching rule

1.Purging rule: If contains such that and then can be eliminated.

2.Discarding or searching rule: It represents the remaining of a pair with less profit and more weights.

Algorithm:

Algorithm DKP(p,w,n,m)

//problem description: This is an algorithm to fill the given knapsack of capacity m by taking the given objects such that profit //will be maximized.

//input: Profits and weights of object and knapsack capacity m.

//output: The considered objects for the knapsack.

{

{

     

}

where is the large is any pair in such that  

}

Merge is a predefined function.

Trackback is also a predefined algorithm.

Add a comment
Know the answer?
Add Answer to:
Show that the decision version of the knapsack problem is NP-complete. (Hint: In your reduction, make...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT