167
The knapsack problem
Should you steal the stereo or not?
You have a knapsack of capacity 1 lb. Will the stereo fit in there? Nope,
it’s too heavy! Because you can’t fit the stereo, $1,500
remains
the max
guess for a 1 lb knapsack.
Same thing for the next two cells. These knapsacks
have a capacity of
2 lb and 3 lb. The old max value for both was $1,500.
The stereo still doesn’t fit, so your guesses remain unchanged.
What if you have a knapsack of capacity 4 lb? Aha: the stereo finally fits!
The old max value was $1,500, but if you put the stereo in there instead,
the value is $3,000! Let’s take the stereo.