Dynamic Programming21 sections · 916 units
Open in Course

Matrix Chain Multiplication - State Definition

What dp[i][j] means

Define dp[i][j]dp[i][j] = minimum cost to multiply matrices from i to j (inclusive). Base case: dp[i][i]dp[i][i] = 00. A single matrix requires no multiplication. Goal: find dp[1][n]dp[1][n], the minimum cost to multiply all matrices. Each dp[i][j] must capture everything needed to solve that range independently.

If you are missing information, you cannot compute the answer correctly. If you include too much, your solution will be slow or use too much memory.