0/1 knapsack
Add the items one row at a time; each cell chooses between leaving the item and taking it with less room.
Items (weight:value)1:1, 3:4, 4:5, 5:7capacity 7
Items (weight, value): 1kg $1, 3kg $4, 4kg $5, 5kg $7. Capacity 7. With no items, every capacity is worth 0.
Table of best values: rows are items added so far, columns are capacities 0 to 7; 0 cells filled.
- compare
- swap or write
- settled
Space play · ← → step · Home End jump · drag the strip to scrub