-
Since the substructure and the main structure have a common
problem(to find optimal parentheses),we can define this using a
recursive equation
-
Let m[i,j] be the minimum number of scalar multiplications required to
multiply Ci..j
-
If i=j then m[i,i] = 0(as there are no multiplications required)
-
If i != j then we split the chain of matrices at any arbitrary
point k,i < k < j, such that m[i,j] = m[i,k] + m[k+1,j] +
pi-1pkpj
-
Since k can take j-i values we need to check all the values
to find the minimum
-
The recursive solution becomes
m[i,j] = min{m[i,k] + m[k+1] + pi-1pkpj}