Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

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

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 nth 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

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions