Why it matters

Matrix chain is classic optimization DP. Understanding shapes interval DP.

Advertisement

The architecture

dp[i][j] = min cost to multiply A_i..A_j.

Try each split point k.

Matrix chain DPInterval [i, j]matrices to multSplit at ktry all splitsCombine costdp[i][k] + dp[k+1][j] + ...Interval DP pattern applies to many problems: burst balloons, palindrome partitioning
Matrix chain.
Advertisement

How it works end to end

dp[i][i] = 0.

Length increases 2 to n.

Try all splits k in [i, j-1].

Reconstruct via split points.