Hello, I'm working on a project, and have come to a halt.
I need to get an array of length k, and I need to take that arrays subset if the i'th number was not there, (note; not popping the number, storing it in a string or list): but im lost on how to make a subset AND how to recurse this so after it finishes one branch that it goes up and back down the next branch.
this is my code so far:
public void rec(int k, int index[]){
if (k == 1){
return;
}
int[] subset = new int[index.length-1]; //creation of subset
for (int p = index.length-1; p >= 0; p--) {
subset[p] = index[p];
}
for (int i = 0; i < subset.length; i++) {
//Loop throgh the subsets va; so that we may anchor the next var
rec(k-1, subset[]);//take the last 2 from the index
}
}
To re iterate, I need to;
take an array, get the first val of that array, store it, then create a subset of the array, recurse the subset, after weve gotten to the last value of the array, go back up and go down the next tree. with the NEXT value of the previous subset.