Enhance the Fibonacci program of Fig. 18.5 so that it calculates the approximate amount of time required

Question:

Enhance the Fibonacci program of Fig. 18.5 so that it calculates the approximate amount of time required to perform the calculation and the number of calls made to the recursive method. For this purpose, call static System method current-TimeMillis, which takes no arguments and returns the computer’s current time in milliseconds.

Call this method twice—once before and once after the call to fibonacci. Save each value and calculate the difference in the times to determine how many milliseconds were required to perform the calculation. Then, add a variable to the Fibonacci Calculator class, and use this variable to determine the number of calls made to method fibonacci. Display your results.

Fig. 18.5I // Fig. 18.5: FibonacciCalculator.java // Recursive fibonacci method. import java.math.BigInteger; 23456780

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  book-img-for-question

Java How To Program Late Objects Version

ISBN: 9780136123712

8th Edition

Authors: Paul Deitel, Deitel & Associates

Question Posted: