Matrix Chain Multiplication

Problem Statement

Given a sequence of matrices, find the most efficient way to multiply these matrices together. The problem is not actually to perform the multiplications, but merely to decide in which order to perform the multiplications.

Solution Approach

We'll use dynamic programming to solve this problem. We'll create a table where m[i,j] represents the minimum number of scalar multiplications needed to compute the matrix A[i]A[i+1]...A[j]. We'll fill this table using smaller subproblems and build our way up to the final solution.

Interactive Visualization

Step: 0 of 10

Explanation:

Final Result

The minimum number of multiplications needed is: