Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please use Python as the language to solve this set of problems. Thank you. Part 1 Implement two separate programs that generate the n-th Fibonacci
Please use Python as the language to solve this set of problems. Thank you.
Part 1 Implement two separate programs 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 (fib1 on Page 3 of the textbook), and the second one should implement the iterative algorithm (fib2 on Page 4). You should measure the time it takes for each of these versions (use for example, the timeit 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. Finally, create a table of all your results and plot (using for example, the matplotlib library) the time taken to compute the Fibonacci numbers using fib1 and fib2, with n on the x-axis and time on the y-axisStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started