Consider the following function:
int mystery (int[] numbers, int index) {
if (index == numbers.length - 1)
return numbers[index];
else {
int temp = mystery(numbers, index + 1);
if (temp > numbers[index])
return temp;
else
return numbers[index];
}
}
If initially numbers = [A] and index = 0, what will
be the value returned by this mystery function?
(Either write a number, or write "infinite recursion".)
ANS
This function recursively finds the biggest value in the array.