Skip to content

Latest commit

 

History

History
12 lines (9 loc) · 539 Bytes

File metadata and controls

12 lines (9 loc) · 539 Bytes

Problem 15: The Matrix Chain (Matrix Chain Multiplication)

Problem Statement

Given a sequence of matrices, find the most efficient way to multiply these matrices together. The problem is to find the minimum number of scalar multiplications needed to compute the matrix chain product. Given an array p[] where the i-th matrix has dimensions p[i-1] x p[i].

Input Format

  • An array p of dimensions.

Example

Input: p = [40, 20, 30, 10, 30]
Output: 26000
Explanation: Optimal parenthesization: (A1(A2A3))A4.