Question: Objective: The goal of this assignment is to practice implementing iterative and recursive versions of Fibonacci number computation, and to learn about empirical performance testing

 Objective: The goal of this assignment is to practice implementing iterativeand recursive versions of Fibonacci number computation, and to learn about empirical

Objective: The goal of this assignment is to practice implementing iterative and recursive versions of Fibonacci number computation, and to learn about empirical performance testing to compare the speed of different algorithms. Assignment: Write the following two methods: 1.A method that computes the n-th Fibonacci number. The method must use an iterative algorithm (i.e., a for or while loop). The method header is as follows: long FiboIterative (int n) 2. A method that computes the n-th Fibonacci number using recursion (without caching of values to speed up the algorithm). The method header is as follows: long FiboRecursive(int n) The methods can be public/private or static as necessary. Note that we discussed these methods in the class. Your goal is to determine an empirical estimate of the efficiency of these two algorithms To do this you need to be able to calculate the execution time of a method. This can be done by using a system method to query the current system time before and after executing the method; the time elapsed is the difference between the two. In Java, you can use the method call System.currentTimeMillis) to get the time in milliseconds as a long. If the execution times are very small you can also use System.nanoTime). This method is not as accurate, but you can use it to get greater precision if you are consistently seeing millisecond times of 0 Start with the third Fibonacci number and compute up to the 50-th number in the series (or, compute it up to a number that is feasible in your computer using recursion). Here are the steps to perform: 1.Run the iterative algorithm, recording the elapsed time as described above for each Fibonacci number. To get an accurate estimate of the time taken for a specific you might need to call the method a number of times and average the resulting times 2. Run the recursive algorithm recording the elapsed time as described above for each Fibonacci number Generate a plot in Excel showing the performance trend of the two methods with different n. Put n on the x-axis and the average runtime on the y-axis. You can output the results to the console and copy the values into Excel by hand

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!