Unlimited copies
Unbounded knapsack is like the zero one version, but each item type is available in unlimited supply. Coin change and rod cutting are common instances. The state can be a single dimension dp at w, the best value achievable at capacity w.
The recurrence
For capacity w, try every item that fits and take the best:
- For each item, consider its value plus dp at w minus its weight.
- Keep the maximum across all items.
Because the same item may be reused, the take branch reads the current capacity table, not a previous item row. This is the precise difference from the zero one case.
Iteration order
Fill capacities from small to large. When you reach dp at w, smaller entries are final, so reusing an item simply layers another copy onto an already optimal smaller solution.
Key idea
Unbounded knapsack reuses items freely by reading the current capacity table and sweeping capacities upward, so each entry can stack additional copies of any item onto smaller optimal answers.