hello,
i've a recursion function, the problem is that when the recursion ends and begins to return it doesn't keeps the values of the arrays it transforms from one function call to another.
|
Code:
|
public static boolean solveHelper(int[][] phi, int[] mu, int[][] backup_phi) {
boolean satRes=false;
int literal;
for(int i=0;i<phi.length;i++) {
if(phi[i].length==1) {
literal=phi[i][0];
int[] temp_arr = new int[mu.length+1];
for(int j=0;j<mu.length;j++) {
temp_arr[j]=mu[j];
}
temp_arr[mu.length]=literal;
phi=substitute(literal, phi);
mu=temp_arr;
i=0;
}
}
literal=selectLiteral(phi);
boolean allEmpty=false;
for(int i=0;i<phi.length;i++) {
if(phi[i].length != 0) {
allEmpty=true;
}
}
if(literal==0 || allEmpty==false) {
if(satisfies(mu, backup_phi)) {
return !satRes;
}
else {
return satRes;
}
}
else {
int[] new_mu = new int[mu.length+1];
for(int i=0;i<mu.length;i++) {
new_mu[i]=mu[i];
}
new_mu[mu.length]=literal;
phi=substitute(literal, phi);
mu=new_mu;
return solveHelper(phi, mu,backup_phi);
}
} |
when the recursion ends, the array mu doesn't have the values it has at the last iteration of the recursion, please help with that.
Thank You