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

2n

B

Fib(n) + 1

C

(2^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.

No comments yet. Be the first to comment!

AI Tutor

How can I help?

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