| preferred AP College board partner for AP classes
AP Computer Science A/Unit 10: Recursion
Start Practice TestPractice Test
About Exam
easy
Recursive Method Call Count
< Prev
Next >

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

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

Question Leaderboard

Not enough data yet to show leaderboard.

No comments yet. Be the first to comment!

AI Tutor

How can I help?

APFIVE © 2020.
Email: [email protected]|Privacy Policy