next up previous
Next: Recursive Solution Up: CSE 2320: Algorithms and Previous: Step 1: Characterize Structure

Step 2: Define recursive solution



Let \(A_{i .. j} \;=\; A_i A_{i+1} .. A_j\), where Ai has dimensions P[i-1] x P[i]. P is an array of dimensions.

For now, the subproblems will be finding the minimum number of scalar multiplications m[i,j] for computing Ai .. j(1 $\leq$ i $\leq$ j $\leq$ n).

Define m[i,j].


\begin{displaymath}m[i,j] = \left\{ \begin{array}{ll} 0 & {\rm if} \; i=j \\
m...
...,j] + P[i-1]P[k]P[j] & {\rm if} \; i<j \\
\end{array} \right.\end{displaymath}

Note that a recursive algorithm based on this definition would still require exponential time.



Copyright © 1998 The University of Texas at Arlington