AlgoPlus//dynamic programming / knapsack-01
Read the theory

0/1 Knapsack

Fill a weight-limited bag for maximum value — each item taken whole or left behind.

Phase
Done
Capacity
Best value
Your items (value/weight, comma-separated)
Legend
Current cell
Derived from
In the bag
AI Tutor Workspace
In a nutshell
The 0/1 knapsack problem packs a weight-limited bag from a set of items — each taken whole or left behind — to maximize total value. It fills a table answering 'best value from the first i items within capacity w', building every larger answer from smaller ones so each case is solved exactly once.
Ready
Press play to begin the cinematic walkthrough.
For each item ask: is the bag worth more with it or without it? The table remembers the best answer for every (items-seen, capacity-left) pair so you never recompute.
Key terms
Go deeper in the lesson
Read the full theory, intuition & complexity for 0/1 Knapsack.