0/1 knapsack problem
- An object is either included or not included in the knapsack. i.e., xi = 0/1, 1 ≤ i≤ n Thus the problem can be stated as:
And xi = 0 or 1, I <= i <= n
- Fractional knapsack problem exhibits greedy choice property. Greedy algorithm exists.
- 0/1 knapsack problem does not exhibits greedy choice property. No greedy algorithm exists.
- It exhibits optimal substructure property. Only dynamic programming algorithm exists.
- Let Si represent the possible states resulting from the decision sequences
Si = { (P,W) }
Where P – total profit earned
W – total weight of objects included
Si 1 = { (P,W) / (P-pi, W-wi) E Si }
Si+1 = Si + Si1