proof of the 0/1 knapsack problem has a optimal sub-structure
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:
) 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.
There is no known Greedy strategy that is optimal for solving the 0/1 Knapsack problem. For each of the following strategies give a counterexample, i.e. descibe an instance where that strategy will fail to produce an optimal result. (a) Lightest item first. (b)Most valuable item first. (c)Item with the best value to weight ratio first.
In 0-1 Knapsack Problem, what is maximized in the optimal solution? A.) Total Value B.) Total Weight C.) Total number of Items D.) Total Volume of Items E.) Total Value/ Total Weight
Consider the integer knapsack problem. Give a recursive algorithm (call it Find-Optimal-Subset) that finds the optimal subset of items through post-processing, that is, after filling in the memorization table to find the maximum total value of the optimal subset of items. (The algorithm we studied in class finds only the maximum total value, not the actual optimal subset of items.) Hint: Trace back through the array M[0..n,0..W] following the optimal structure.
True or False: A greedy approach is guaranteed to find the optimal solution to the Knapsack 0-1 problem. True False
Design a local search algorithm for the 0-1 knapsack problem. Assume there are n items x1 ... xn each with weight wi and value vi. The knapsack can have at most one of each item and the total weight cannot exceed W. You want to maximize the total value in the knapsack.Question 1: (7 points) Show the psuedocode/explanation for your algorithm.Question 2. (3 points) Is it guaranteed to find an optimal solution? Justify your answer.
The 0-1 knapsack problem is technically an optimization problem: You’re trying to maximize the value of goods within a particular weight. Define a decision problem which can be used to solve the 0-1 knapsack optimization problem
For given capacity of knapsack W and n items {i1,i2,...,in} with its own value {v1,v2,...,vn} and weight {w1,w2,...,wn}, find a greedy algorithm that solves fractional knapsack problem, and prove its correctness. And, if you naively use the greedy algorithm to solve 0-1 knapsack problem with no repetition, then the greedy algorithm does not ensure an optimal solution anymore. Give an example that a solution from the greedy algorithm is not an optimal solution for 0-1 knapsack problem.
1) Use the Breadth-First-Search with Branch-and-Bound Pruning
algorithm for the 0–1 Knapsack problem to maximize the profit for
the following problem instance. Show the actions step by step.
2) Use the Best-First Search with Branch-and-Bound Pruning
algorithm for the 0–1 Knapsack problem to maximize the profit for
the following problem instance. Show the actions step by step.
i PiPi 1 $20 210 2 $30 5 6 3 $35 75 4 $12 3 4 5 $3 13 wi Wー13
1. Fractional Knapsack Problem Algorithm Which best describes the tightest range of the number of items with only fractional inclusion (i.e. not entirely included or excluded) in the knapsack? (Let n denote the number of items for possible inclusion.) A) At least 0 items and at most n items B) At least 1 items and at most n items C) Exactly n items D) At least 0 items and at most n-1 items E) At least 1 items and at...
Recall that in the "Knapsack Problem", there are n items having respective values V1..n) and weights W1..n), all greater than 0 and one needs to maximize the total value of the subset of the items placed in the knapsack limited by a weight capacity of W In the 0-1 Knapsack Problem, each item must be either be included or excluded in its entirety, in light of the fact that this problem is to be "NP-Complete", how can one solve the...