title | date | lastmod |
---|---|---|
Knapsack Problem |
2022-11-08 |
2022-11-21 |
Given n items where the
Find the largest total value of items that fits in a knapsack of capacity
Let
Base case: Capacity or number of items is 0
Maximizing by the profit per weight:
0 | 1 | 2 | 3 | 4 | |
---|---|---|---|---|---|
0 | 0 | 0 | 0 | 0 | 0 |
1 | 0 | 0 | 0 | 0 | 0 |
2 | 0 | 0 | 0 | 0 | 0 |
3 | 0 | 0 | 0 | 0 | 50 |
4 | 0 | 0 | 40 | 40 | 50 |
5 | 0 | 10 | 40 | 40 | 50 |
6 | 0 | 10 | 40 | 40 | 50 |
7 | 0 | 10 | 40 | 40 | 90 |
8 | 0 | 10 | 40 | 40 | 90 |
9 | 0 | 10 | 50 | 50 | 90 |
10 | 0 | 10 | 50 | 70 | 90 |