Knapsack Algoritma Weakness
Knapsack Algoritma Weakness
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. Item 1: x1=$5 ; w1=3t Item 2: x2=$7 ; w2=4t Item 3: x3=$8 ; w3=5t
Knapsack Problem
Output function f(i,w)
Knapsack Problem
Table
1 1 2 3 f(i,w) i 2 3 4 5 6 7 8 9 10 W
Knapsack Problem
Table
1 1 2 3 2 3 4 5 6 7 8 9 10 W
Knapsack Problem
Table
1 1 2 3 Using only item 1 & 2 2 3 4 5 6 7 8 9 10 W
Knapsack Problem
Table
1 1 2 3 Using items 1, 2 & 3 2 3 4 5 6 7 8 9 10 W
Knapsack Problem
Table
1 1 2 3
0 items n1
1 items n1 w1 = 3 2 items n1 2 w1 = 6
2 0
3 5
4 5
9 10
5 10
Knapsack Problem
Table
1 1 2 3
+ x2 (= 7)
2 0 0
3 5 5
4 5 7
9 10
0 0
5 10 10 10 15 15
w w2 = 54=1
Knapsack Problem
Table
1 1 2 3
+ x2 (= 7)
2 0 0
3 5 5
4 5 7
5 7
9 10
0 0
5 10 10 10 15 15
Knapsack Problem
Table
1 1 2 3
+ x2 (= 7)
2 0 0
3 5 5
4 5 7
5 7
9 10
0 0
5 10 10 10 15 15
w w2 = 64=2
Knapsack Problem
Table
1 1 2 3
+ x2 (= 7)
2 0 0
3 5 5
4 5 7
9 10
0 0
5 10 10 10 15 15 7 10
Knapsack Problem
COMPLETED TABLE
1
1 2 3 0 0 0
2
0 0 0
3
5 5 5
4
5 7 7
5
5 7 8
10
10 10 10 15 15 10 12 14 15 17 10 12 14 15 17
Knapsack Problem
Path
1 1 2 3 0 0 0
Item 1
2 0 0 0
3 5 5 5
4 5 7 7
5 5 7 8
Item 1
10
10 10 10 15 15 10 12 14 15 17 10 12 14 15 17
Item 2