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?
preguntado el 08 de noviembre de 11 a las 12:11
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
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.