I am trying to find complexity of Fibonacci series using a recursion tree and concluded height of tree = O(n) worst case, cost of each level = cn, hence complexity = n*n=n^2
How come it is O(2^n)?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The complexity of a naive recursive fibonacci is indeed 2ⁿ.
In each step you call
Ttwice, thus will provide eventual asymptotic barrier of:T(n) = 2⋅2⋅...⋅2 = 2ⁿbonus: The best theoretical implementation to fibonacci is actually a close formula, using the golden ratio:
(However, it suffers from precision errors in real life due to floating point arithmetics, which are not exact)