You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
given solution is completely right ...but here is the more optimized solulion without using any loop after solving the recurrence relation of the fibonacci number we will get a direct formula to get the nth fibonacci term. On further solving the formula we will get the time complexity of this program as golden ration raised to the power n which is equal to O(1.6180)^n.
The text was updated successfully, but these errors were encountered:
Exercise 18.02 says:
"*18.2 (Fibonacci numbers) Rewrite the fib method in Listing 18.2 using iterations."
The purpose of this exercise is actually to use a traditional iterative or looping approach to solving fibinanci numbers.
*The goal is not to write the fastest or most optimized algorithm, but to teach the utility of recursion by contrast with iteration.
given solution is completely right ...but here is the more optimized solulion without using any loop after solving the recurrence relation of the fibonacci number we will get a direct formula to get the nth fibonacci term. On further solving the formula we will get the time complexity of this program as golden ration raised to the power n which is equal to O(1.6180)^n.
The text was updated successfully, but these errors were encountered: