🎒 Knapsack: Fractional vs 0/1
See why Greedy works for Fractional but FAILS for 0/1 Knapsack
Setup: Capacity = 50 kg. Items sorted by value/weight density (greedy order).
Greedy Strategy: Take items with highest $/kg first.
Click "Next Step" to begin filling the knapsack greedily.
✅ Fractional Knapsack
Can take portions of items (Greedy WORKS)
Capacity: 50/50 kg
| Item |
Weight |
Value |
$/kg |
Take |
❌ 0/1 Knapsack
Must take whole items or nothing (Greedy FAILS)
Capacity: 50/50 kg
| Item |
Weight |
Value |
$/kg |
Take |