I am reading Introduction to Algorithms by Cormen etc on dynamic programming.

Here is text snippet which gives some back ground

the problem of matrix-chain multiplication exhibits optimal substructure. We observed that an optimal parenthesization of A1 A2 ... An that splits the product between Ak and Ak + 1 contains within it optimal solutions to the problems of parenthesizing A1 A2 ... A k and Ak + 1 Ak + 2 . . . An.

In the book for Matrix-chain multiplication there are theta(n square) subproblems.

My question is how does author came up with there are n square sub problems? Can any one pls give example how we came with this?

¡Gracias!

preguntado el 08 de noviembre de 11 a las 12:11

This question is too hard to answer without immediate access to the Cormen book. You should try to flesh things a little bit more and make the question self-contained. -

## 1 Respuestas

Each subproblem involves solving the problem for a consecutive subsequence of matrices `Ai, Ai+1, ..., Aj-1, Aj`. This subsequence is characterized by the two indices `i` y `j`. Puesto que hay `n` possible choices for each, the number of subproblems is theta(n2). The exact number is `n(n+1)/2` due to the constraint `i <= j`.

respondido 08 nov., 11:18

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.