Question: Appreciate a step by step explanation to this question. Write two separate programs in python that generate the n-th Fibonacci number. The programs should both

Appreciate a step by step explanation to this question.

Appreciate a step by step explanation to this question. Write two separate

Write two separate programs in python that generate the n-th Fibonacci number. The programs should both take n as command line input. The first algorithm one should implement the recursive algorithm, and the second one should implement the iterative algorithm. Measure the time it takes for each of these versions (use for example, the time it module in python) to calculate the n-th Fibonacci number for the following values of n: 1, 5, 10, 15, 20, 25, 30, 35, 40, 41, 42, 43. Create a table of all your results and plot (using for example, the mat plot lib library) the time taken to compute the Fibonacci numbers using recursive and iterative algorithms, with n on the x-axis and time on the y-axis. Prove that the iterative algorithm is in quadratic time. Run the iterative algorithm and record the time on the following values of n: 2^10, 2^12, 2^14, 2^16, 2^18, 2^19 b.Plot the time of the iterative algorithm version

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!