next up previous
Next: Up: Previous:

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


next up previous
Next: Up: Previous: