Recursive Method Call Count
Consider the following method.
public int computeSum(int n) {
if (n == 0)
return 0;
else
return n + computeSum(n - 1);
}
If n is a positive integer, what is the total number of times the computeSum method is invoked by the call computeSum(n), including the initial call?
A
n^2
B
n-1
C
2^n
D
n+1
Question Leaderboard
Not enough data yet to show leaderboard.
APFIVE