12int MatrixChainMultiplication(
int dim[],
int i,
int j) {
27 for (
int k = i + 1;
k <= j - 1;
k++) {
29 int cost = MatrixChainMultiplication(dim, i, k);
32 cost += MatrixChainMultiplication(dim, k, j);
35 cost += dim[i] * dim[
k] * dim[j];
51 int dim[] = {10, 30, 5, 60};
52 int n =
sizeof(dim) /
sizeof(dim[0]);
57 cout <<
"Minimum cost is " << MatrixChainMultiplication(dim, 0, n - 1)
double k(double x)
Another test function.