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

Time Complexity of Recursive Fibonacci

Mark
< Prev
Next >

What is the time complexity of the following recursive fib method?

public static int fib(int n) {
    if(n <= 1) return n;
    return fib(n-1) + fib(n-2);
}
A

Exponential time, approximately O(2^n).

B

Logarithmic time, O(log n).

C

Quadratic time, O(n^2).

D

Linear time, O(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|