Knapsack Problem: Truck - 10t Capacity
Knapsack Problem: Truck - 10t Capacity
•Item 1: $5 (3t)
•Item 2: $7 (4t)
•Item 3: $8 (5t)
Knapsack Problem
Output function f(i,w)
Optimum output of a combination of items 1
to i with a cumulated weight of w or less.
f(i,w)
i
Knapsack Problem
Table
1 2 3 4 5 6 7 8 9 10 W
1 Using only item 1
2
3
i
Knapsack Problem
Table
1 2 3 4 5 6 7 8 9 10 W
1
2 Using only item 1 & 2
3
i
Knapsack Problem
Table
1 2 3 4 5 6 7 8 9 10 W
1
2
3 Using items 1, 2 & 3
i
Knapsack Problem
Table
1 2 3 4 5 6 7 8 9 10 W
1 0 0 5 5 5 10
2
3
COMPLETED TABLE
1 2 3 4 5 6 7 8 9 10
1 0 0 5 5 5 10 10 10 15 15
2 0 0 5 7 7 10 12 14 15 17
3 0 0 5 7 8 10 12 14 15 17
Knapsack Problem
Path
1 2 3 4 5 6 7 8 9 10
1 0 0 5 5 5 10 10 10 15 15
2 0 0 5 7 7 10 12 14 15 17
3 0 0 5 7 8 10 12 14 15 17