For Educators · 0/1 Knapsack
0/1 Knapsack for a knapsack
Built for educators teaching it to a class. Drop a live demo into a lecture or assign it as a shareable link — no lab installs. Simulate a knapsack live below — adjust the inputs and watch it respond, right in your browser.
0/1 KnapsackLive
dynamic programming optimization
Camera
4 kg
$500
packed
Laptop
8 kg
$700
packed
Water
3 kg
$200
packed
Tent
10 kg
$400
left
Food
5 kg
$300
packed
Book
2 kg
$90
left
Radio
6 kg
$260
left
Rope
3 kg
$130
left
Controls
Presets
The knapsack problem: pick items to maximize value without exceeding a weight limit. Greedily grabbing the most valuable item fails; the optimal answer needs dynamic programming, which builds a table of best values for every capacity. It models budgeting, cargo loading, and resource allocation — and is a classic NP-hard problem solved efficiently by DP.
Data Inspector
Total value$1700
Weight used20 / 20 kg
Items packed4
Governing equation
Reading this result: DP fills all 20 kg for $1700; notice the best pack is not simply the highest-value items — it trades value against weight, which is exactly why greedy selection fails here.
Runs locally in your browser — free forever. Scale to the cloud when reality gets heavy.
Also for:StudentsResearchersEngineersHobbyists & MakersK-12 StudentsFirst RespondersGeneral version →
More with 0/1 Knapsack
Frequently asked questions
- Is this good for educators?
- Yes — this version of "0/1 Knapsack for a knapsack" is framed for educators teaching it to a class. Drop a live demo into a lecture or assign it as a shareable link — no lab installs.
- Do I need to install anything?
- No. It runs in any modern browser, free, with no account required.