next up previous
Next: Dynamic Programming Solution (4 Up: CSE 2320: Algorithms and Previous: Matrix Multiplication Parenthesization

Brute Force Solution: Try all possible parenthesizations

How many?

\(A_1 A_2 ... A_k \mid A_{k+1} ... A_{n-1} A_n\)
P(k)*P(n-k), k = 1 to (n-1)

\begin{displaymath}P(n) = \left\{ \begin{array}{ll}
1 & n=1 \\
\sum_{k=1}^{n-1} P(k) P(n-k) & n>1
\end{array} \right.\end{displaymath}

See Cormen et al., Problem 13-4 for solving this recurrence.
P(n) = \(\frac{1}{n} \left( \begin{array}{c} 2n-2 \\ n-1 \end{array} \right)\)
= \(\Omega(\frac{4^{n-1}}{(n-1)^\frac{3}{2}})\), which is exponential in n.

Copyright © 1998 The University of Texas at Arlington