| preferred AP College board partner for AP classes
AP Computer Science A/Unit 10: Recursion
Start Practice Test
Share
medium Solved by 11 students
Maximum Recursion Depth
< Prev
Next >

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

16

B

4

C

5

D

6

Hint
Did You Know?
Explain Why
Explain All Answers
Check Answer
Show Correct Answer

Question Leaderboard

Rank
User
Correct Count
Attempt Count
Time
Score
#1mtanarupi22 0m 00s 200
#2songqiuhui201211 0m 35s 65
#3ethan01 0m 00s -10
#4psak1212 2m 18s -48
#5suhanakochhar00634 6m 12s -82
#6ravi.palepu01 1m 16s -86
#7singhris00002 5m 55s -375
APFIVE © 2020.
Email: apfive@apfive.org|Privacy Policy