Question

proof of the 0/1 knapsack problem has a optimal sub-structure

proof of the 0/1 knapsack problem has a optimal sub-structure

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

What is 0/1 knapsack problem?

Let there is a knapsack (or rucksack ) of capacity W.

n items are placed on this knapsack. {Weights and values of n items (given as array weights[ ] and values[ ])

where weights[0..n-1] are the weights items

values[0…n-1] are the values of items

}

The 0/1 knapsack problem here is to sort out highest value subset of values[ ], where the total of weights of the subset <=W, capacity of knapsack.

Here 0 denotes don’t take anything from knapsack

or

take full items in knapsack

What is a solution for this problem?

0/1 Knapsack problem possess 2 properties of a dynamic programming problem:

- overlapping sub-problems property

- Optimal Substructure property

While discussing second property we can see that:

By considering every subset of items (then 2 scenarios are there:

  1. item is in optimal subset
  2. not in optimal set

) and finding the weight sum and value sum of every subset this problem can be solved. Then take only subsets whenever weight sum < W. Then from those, take the subset with maximum value.

Proof:

Let I be the set of items,

val means valuesv

wt means weight.

Let some solutions X′⊆I−{k}is good solution than X−{k}.

Then X′≠X, the value is high, val(X′)>val(X−{k}),

and k∉X′

and wt(X′)≤W−wt(k)

Now add k to X′ to obtain X′′=X′∪{k}

wt(X′′)=wt(X′)+wt(k)≤wt(X′)≤W

so X″ weighs less than W the capacity of knapsack, so X″ is a solution where knapsack weighs < max weight.

val(X′′)=val(X′)+val(k)

By assumption, val(X′)>val(X−{k})

so, adding val(x) to 2 sides of this final eq, val(X′)+val(k)>val(X−{k})+val(k)=val(X)

Hence val(X′′)>val(X)

Contradiction!!

We assumed X was better solution but X’’ is the best solution where knapsack weighs < max weight.

Add a comment
Know the answer?
Add Answer to:
proof of the 0/1 knapsack problem has a optimal sub-structure
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