Parenthesization of two subchains
A1 .. Ak and
Ak+1 .. Anmust each be optimal for
A1 .. An to be optimal.
Why? A lower cost solution to a subchain reduces the cost of
A1 .. An. The total cost is calculated as cost(
A1 .. Ak) +
Ak+1 .. An) + cost of multiplying two resultant matrices together.
The last term is constant no matter what the subproblem solutions are.
We can show that if the subproblem does not have an optimal solution, a
better subproblem solution cost yields a better total cost.
Thus, as is the case with ALL Dynamic Programming solutions, an optimal solution
to the problem consists of optimal solutions to subproblems.
This is called ? optimal substructure .