next up previous
Next: Elements of Dynamic Programming Up: CSE 2320: Algorithms and Previous: Dynamic Programming

Step 4: Construct Optimal Solution



Let A = \(\langle A_1, A_2, .., A_n \rangle\).

Call Matrix-Chain-Order then Matrix-Chain-Multiply, defined below.

Matrix-Chain-Multiply(A, s, i, j)
$\;\;\;\;\;$if i < j
$\;\;\;\;\;$then x = Matrix-Chain-Multiply(A, s, i, s[i,j])
$\;\;\;\;\;$ $\;\;\;\;\;$y = Matrix-Chain-Multiply(A, s, s[i,j]+1, j)
$\;\;\;\;\;$ $\;\;\;\;\;$return Matrix-Multiply(x, y)
$\;\;\;\;\;$else return Ai



Copyright © 1998 The University of Texas at Arlington