Link to home
Start Free TrialLog in
Avatar of ubuntuguy
ubuntuguyFlag for United States of America

asked on

Calculate fibonacci series in linear time

Is there a way to calculate the fibonacci series in linear time instead of O(n^2)?
Avatar of ozo
ozo
Flag of United States of America image

where n means the nth  fibonacci number?
If you can do additions in O(1) then yes.
= get yourself a really, really big ALU chip :)
ASKER CERTIFIED SOLUTION
Avatar of javaexperto
javaexperto
Flag of Mexico image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
that's O(n) as long as f(n) is small enough to fit in an int
if adding large numbers is O(log(f(n)) then this method becomes O(n^2)