// A program to sort an array of numbers by Charles Nye // best with a dense set of numbers, with few gaps between. #include #include #include #include #include #include using namespace std; //helper function taken from Olaf's program: void printArray(int *arr, int N) { for ( int i=0; i getinputvector( const int length){ //initialize rand with a seed srand ( time (NULL)); vector input; input.reserve ( length ); for (int i=0; i> length; vector input = getinputvector(length); if ( verbose ) { cout << "Input: "; printArray(input, length); } //find the min and max values in the array by pulling ever bigger and smaller ones out. int maxval = input[0]; int minval = input[0]; for (int i=0; i maxval) maxval = input[i]; if (input[i] < minval) minval = input[i]; } if ( verbose ) { cout << "Max/Min are: " << maxval << " " << minval << endl; } //assert: maxval and minval are the largest and smallest numbers in start[] //set up the expanded array to sort into. "()" will initialize it to "0". int range = (maxval-minval+1); int * expanded = new int[(range)](); if ( verbose ) { cout << "Range is: " << range << endl; } //fill the expanded array. for (int i=0; i