Question: Consider the algorithm for the Fibonacci sequence. a) Write a recursive algorithm which computes F(n) for and show that its running-time complexity is exponential with

Consider the algorithm for the Fibonacci sequence.

a) Write a recursive algorithm which computes F(n) for Consider the algorithm for the Fibonacci sequence. a) Write a recursive algorithm and show that its running-time complexity is exponential with n. Hint: the Fibonacci number can be approximated as which computes F(n) for and show that its running-time complexity is exponential where with n. Hint: the Fibonacci number can be approximated as where is is the golden ratio (= the golden ratio (= = 1.61801.. ) and [.] denotes rounding to = 1.61801.. ) and [.] denotes rounding to the nearest integer.

b) Add memoization to the recursive algorithm and show that the running-time is 0(n)..

c) Reimplement the memoized recursive algorithm as a bottom-up iterative algorithm. (Note an optimality substructure is not in this exercise.)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!