Use the Stopwatch to time the functions:
Stopwatch timer = new Stopwatch(); ... initialize arguments first timer.start(); ... code to be timed timer.stop(); System.out.println(timer);
For daffy and donald, time the functions for values of n from 30 through 44 . Plot these times (if appropriate) on semi-log paper.
For mickey, minnie, goofy, and pluto, initialize by making an array of size n with randomarr(n). The initialization of the array should not be inside the timing calls. Use values of n of 1000, 2000, 4000, 8000 ... through 256000 (for mickey, go up to 8192000).
For gyro, make an array using randomarr(n) and call pluto on it first. (pluto should not be included in the timing). Use values of n of 1000, 2000, 4000 ... through 256000 .
For fact(BigInteger n), test on values of n from 1000 through 64000, doubling each time. You can make a BigInteger using code such as:
BigInteger bign = BigInteger.valueOf((long) 1000);A BigInteger bign that is not too large can be converted to an int using bign.intValue() . There are operations .add(), .subtract(), .multiply(), and .divide(), each with a BigInteger argument (this is just for your information).
For each of the functions, plot the time taken vs. n on log-log paper and estimate the big-O for the function. Note that the timer will not be accurate for very small times, e.g. less than a millisecond (0.001 second). If all the times of a function are too small, just report that the function is too fast to measure (and don't plot it). Do not include times that are too small in your plots, since the reported times are just noise.
For mickey, minnie, goofy, and pluto, also estimate the Big O of each function using the ratio of times as the input size is doubled. The time of the stopwatch in seconds can be obtained (as double) as timer.time(). For small values of the input size, the times will be noisy and the ratio will not be meaningful, so you may need to ignore the first few ratio values and concentrate on the ratios for larger inputs.