Labs / Computer Science
Knapsack Packer
You have a bag with a weight limit and a pile of items, each worth some money. Which items should you take to walk away with the most value? Watch the dynamic-programming table fill in one cell at a time, then light up the winning subset by tracing back through its own decisions. Drag any item card to change its weight & value and the whole solution re-solves.
best …items …load –greedy off
What to try
- Each new cell only looks at two older cells. Can you spot which two the amber outlines point to, and why those?
- Turn on the greedy solver. When does grabbing the best value-per-kg item first actually miss the true optimum?
- Drag an item to make it heavier without changing its value. At what weight does it drop out of the chosen set?
- Shrink the capacity one kilogram at a time. Does the best value fall smoothly, or does it jump?
- Add a fifth or sixth item — how many more cells does the table need before it finishes?