Sorting |
To run the sorting driver,
- Initially, select a size of 1,000.
- Choose random values (the default).
- Choose NOT to print before/after values (the default).
- Choose NOT to verify that the array is sorted (NOT the default).
- Choose an O(N^2) sorting method (b, s, or i).
Write in the method in B1 of the spreadsheet.
- Choose to sort this same array 10 times.
- Write in the Fastest, Slowest, and Average times in the appropriate
column of the spreadsheet; other cells will automatically be filled in.
- Choose a new array (n) and repeat the above process for sizes
2,000, 4,000, 8,000, and 16,000 element
arrays.
Repeat this process for an O(N log N) sorting method
(m, q, h, or a) for arrays containing
50,000, 100,000, 200,000, and 400,000, and
800,000 elements
- Notice how doubling in size affects the average running time of each method
(the Ratio rows).
- Notice the Spread when sorting the same arrays;
this gives a bound on the accuracy of any such computations.
- Generally, Java's system clock is accurate only to about 1 millisecond
(.001 seconds).
- Notice the simple computation of C for the equation
T(N) = ...
(look at the cell; this would be easy to do on a calculator and easy to
do by hand if you can estimate the logarithmic function).
- Notice the Error when using just the last N and T(N)
to compute C and using it to predict the other times.
|