Question: Solution 3 ( b ) Loop Invariant: ( Hint: Your loop invariant should ensure that the output in the final iteration, i . e .
Solution b
Loop Invariant:
Hint: Your loop invariant should ensure that the output in the final iteration, ie decision stage, is the optimal set of items with maximum total value that fits in the Knapsack.
In the reminder of this proof, the loop invariant holds true in every iteration decision stage:
Initialization:
Maintenance: Assume the loop invariant holds true at the end of iteration. Then, during the iteration, let the residual capacity of the Knapsack be next item picked by GreedyFracknapsackitems
Termination:
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
