Question
Part 2: Java Programming (Recursion/Iteration Comparison) [65 points] A Fibonacci series of numbers is characterized as the following: 0 1 1 2 3, where the
Part 2: Java Programming (Recursion/Iteration Comparison) [65 points] A Fibonacci series of numbers is characterized as the following: 0 1 1 2 3, where the sum of the previous two numbers equal the current number. With that in mind implement a recursive function called fiboSeriesRec that will produce the Fibonacci series of numbers output up to a predefined n (input by the user). This means that the user will first enter the nth Fibonacci series number and your program will have to calculate the number up until the n th value. After that implement an iterative function called fiboSeriesIte that will produce the Fibonacci series of numbers output up to a predefined n; iteratively. Recall that iterating typically means using some kind of loop (hint: use a for loop).
(Ex: User input n = 3
Fibonacci series program output: 0 1 1
User input n =5
Fibonacci series program output 0 1 1 2 3 )
Lastly, utilizing a timing library, time the run time to calculate and display the Fibonacci series to the user define nth number. Test a variety of inputs when utilizing a recursive method, and test a variety of different inputs when utilizing an iterative method of generating a Fibonacci series. This essentially means you will be utilizing a Java timing library, where you initiate some variable like a stopwatch before the numbers are generated to time how long it took and as soon as execution is complete stop timing and output it to the console.
You must run five different tests on both the iterative and recursive program: n=10 n=20 n= 30 n=40 n = 50
Record the timing for each one and make a graph to compare it. In 100-200 words analyze which one was faster and why. Ensure that your code is well commented where it makes sense.
Step 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