| preferred AP College board partner for AP classes
AP Computer Science A/Unit 5: Writing Classes
Start Practice TestPractice Test
About Exam
hard Solved by 6 students
Recursive Fibonacci Time Complexity
< Prev
Next >

What is the time complexity in Big-O notation for the fib method in the FibonacciCalculator class shown below?

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

O(n)

B

O(2^n)

C

O(n^2)

D

O(log n)

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

Question Leaderboard

Rank
User
Correct Count
Attempt Count
Time
Score
#1kaisuki12 0m 00s 90
#2bommasam00028 2m 07s 13
#3y.seong202712 1m 32s -2
#4ravi.palepu01 0m 22s -32
Items per page:
10
1 – 4 of 4
No comments yet. Be the first to comment!

AI Tutor

How can I help?

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