问题
I have the next method:
public static int maxFind(int [] a, int length)
{
if (length == 1){
return a[0];
}
// recursively maxFind method on length-1
int result = maxFind(a, length - 1);
if (a[length - 1] > result)
return a[length - 1];
else
return result;
}
I've finished that work, and pass some time from when i saw a tutorial of that method and i always forget the idea of recursion. i think that if someone will explain me every step of this method - i will get the idea once for all.
Example - my arr is: {1,1,0,2)
What is the steps here when we running this method? what is the value on result, and what is the role of (a, length-1) ? (i've tried the debugger but it's not helped me)