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
hard

Recursive Fibonacci Method Calls

Mark
< Prev
Next >

Consider the calculateFibonacci method provided below.

public int calculateFibonacci(int n) {
    if (n == 0 || n == 1)
        return n;
    else
        return calculateFibonacci(n - 1) + calculateFibonacci(n - 2);
}

For an integer n > 1, what is the total number of calls to calculateFibonacci required to evaluate calculateFibonacci(n), including the initial call?

A

(2^n) - 1

B

2n

C

Fib(n) + 1

D

n

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|