Are you taking CLEP classes? Try clep.ai
| 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

Mark
< 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

2^n

B

n-1

C

n^2

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.

AI Tutor

How can I help?

APFIVE © 2020.
Email: apfive@apfive.org|Privacy Policy|