AlgoScope

Unbounded Knapsack

Algorithmintermediate2D Dynamic Programming

Items may repeat; the transition reads the same row instead of the previous one.

Decision · step 3 of 34Knapsack: Unbounded, the same items
012345670i1i2i3i40✓00✓0✓0✓0✓0✓0✓01✓

Item 1 (weight 1, value 1) at capacity 1. Skip: 0 from above. Take: 1 + 0 from this row at capacity 0 = 1. Best: 1, take.

Open in the player →or start at step 3

What you will see

The left-arrow stays in the current row; contrast with 0/1.

How knapsack works →

Cost

BestO(n * W)
AverageO(n * W)
WorstO(n * W)
SpaceO(W)

How you work with it here

play it through, step one change at a time, scrub to any step, run it on your own input, predict what happens next.

Screen readers: Table cells announce their state and value; each step announces which cells were read and the value written.

Reduced motion: Dependency arrows appear statically and the cell value crossfades.

Before this

Taught by the same lesson

Knapsack covers these too, in the same run.