AlgoScope

Interval DP

TechniqueadvancedAdvanced Dynamic Programming

Fill a triangular table by range length; each range takes the cheapest split into two shorter ranges.

Decision · step 2 of 8Interval DP: Merging adjacent piles
412341230✓50✓0✓0✓

dp[0][1], length 2: split at 0: 0 + 0 + 5 = 5. Best is 5, splitting at 0: merge piles 0..0 and 1..1 last, paying their total 5.

Open in the player →or start at step 2

What you will see

The table fills diagonal by diagonal.

How interval dp works →

Cost

BestO(n^3)
AverageO(n^3)
WorstO(n^3)
SpaceO(n^2)

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

Leads to

Topics that need this one first.

Taught by the same lesson

Interval DP covers these too, in the same run.