CSE221 · Algorithms

Knapsack Simulator

Fill the 0/1 DP table cell by cell, then compare it against the fractional greedy answer.

item / cap012345678
none000000000
A·········
B·········
C·········
D·········

Row 0 means "no items available", so every cell is 0. Each cell (i, w) is the best value from the first i items within capacity w.

step 1 of 38

Result

Capacity
8
Best value
—
Items taken
—

Each cell asks one question: is it better to skip this item, or take it and use the best solution for the remaining capacity?

Your items

ItemWeightValue
A23
B34
C45
D56

← → to step, or use the buttons above.