next up previous
Next: Up: Previous:

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.


next up previous
Next: Up: Previous: