Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

heavy-duty recursion problem

hi this is a homework problem so Iam not looking for people to do it for me but any help would be welcome

its computing the number of scalar multiplications neccessary to multiplly matrices and printing out the minimum number need.

here is my code so far

import java.util.*;
import java.io.*;

public class PP4
{
public static void main(String args[])
{
int[] matrix = new int[][]
for(int a = 0; a < args.length; a++)
for(int b = 0; b < args.length b++)
matrix[a][b] =
// supposed to get dimensions of matrices for the arguments
// example java pp4 3(# of matrices) 3 5 2 10(dimensions)
cost(// what goes in here? )
System.out.println("The minimum value is " ?);

}
public static int cost(int[] dims)
{
int[][] m, s;
int n = dims.length - 1;
m = new int[dims.length + 1][dims.length + 1];
s = new int[dims.length + 1][dims.length + 1];
for (int i = 1; i <= n; i++)
m[i][i]=0
for(int L = 2; L <= n; L++)
for(int i = 1; i <= n - L + 1; i++)
{
int j = i + l -1;
m[i][j] = 1%0;
for(int k = i; k<= j - 1; k++)
{
int q = m[i][k] + m[k+1][j] + dims[i-1] * dims[k] * dim[j];
if (q < m[i][j])
{
m[i][j] = q;
s[i][j] = k;
}
}
}
}
}
[1529 byte] By [Mcody2] at [2007-11-11 8:27:04]
# 1 Re: heavy-duty recursion problem
I dont see any recursion in your code. You want help with homework, you're going to have to be a lot more specific with what you need help on.
Phaelax at 2007-11-11 22:35:19 >