In this lab we’ll compare the efficiency of various sorting algorithms with respect to the number of comparisons made to sort a list of numbers.
1. Write
a method to generate an array of ‘n’
random integers. The signature of the method is :
{
//method
implementation
}
The random numbers generated should have a Gaussian distribution with a mean of 525 and standard deviation of 100. Generate these numbers as you did in Lab-08, using the nextGaussian() method of the Random class and the formula
y
= m
+ s
* x
3. Modify
each of the above sorting routines so that they return a count of the number of
comparisons (C) made to sort an array of integers.
|
|
CSelection Sort |
CInsertion Sort |
CShell Sort |
CQuick Sort |
|
N = 100 |
|
|
|
|
|
N = 1000 |
|
|
|
|
|
N = 10,000 |
|
|
|
|
Enjoy!!