Maximum Recursion Depth
Consider the following MaxDepth class. What is the maximum recursion depth when the main method is executed?
public class MaxDepth {
public static int process(int[] arr, int low, int high) {
if(low >= high) return 1;
int mid = (low + high) / 2;
int left = process(arr, low, mid);
int right = process(arr, mid+1, high);
return Math.max(left, right) + 1;
}
public static void main(String[] args) {
int[] data = new int[16];
System.out.println(process(data, 0, data.length - 1));
}
}
A
4
B
6
C
16
D
5
APFIVE