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.5
Step by Step Answer:
Java How To Program Late Objects Version
ISBN: 9780136123712
8th Edition
Authors: Paul Deitel, Deitel & Associates