(Latest Revision:
March 30, 2021)
Solution to Knapsack Problem
============================
Total Weight ----->
obj
# wt val | 0 1 2 3 4 5 6 7 8 9
______________________________________________________
0 0 0 | 0* 0 0 0 0 0 0 0 0 0
1 5 17 | 0* 0 0 0 0 17 17 17 17 17
2 2 16 | 0 0 16* 16 16 17 17 33 33 33
3 4 7 | 0 0 16* 16 16 17 23 33 33 33
4 8 13 | 0 0 16* 16 16 17 23 33 33 33
5 7 19 | 0 0 16 16 16 17 23 33 33 35*
Objects to use in optimal solution: 5 (wt=7;v=19), 2 (wt=2;v=16)
The sum of values of items 5 and 2 is 19+16=35,
which is the last entry in the table, as it should be.
The sum of weights of items 5 and 2 is 7+2=9,
which does not exceed the weight limit of 9.
============================