🎒 Knapsack Problem: Greedy vs DP
See exactly why the Greedy strategy gets trapped in the 0/1 Knapsack problem.
| Item Name |
Weight (W) |
Value (V) |
Ratio (V/W) |
💡 Key Takeaway:
The Greedy algorithm makes local choices (highest ratio). In Fractional Knapsack, this works perfectly because you can take partial chunks of items to fill the bag without wasting space.
However, in 0/1 Knapsack, you can't split items! The Greedy algorithm gets "trapped" taking Item A, which leaves an awkward 3 kg hole that no other items can fill. Dynamic Programming solves this by evaluating all combinations—discovering that entirely skipping the highest-ratio item leaves the perfect amount of room for B and C!