static void quickSortRec(int array[], int lo, int hi) { if (lo >= hi) return; int part = quickPartition(array, lo, hi); quickSortRec(array, lo, part - 1); // sort left partition quickSortRec(array, part + 1, hi); // sort right partition }
void Sorts<T>::quickSortRec(T arr[], int first, int last, bool median) { if (first < last) { int pivotIndex = partition(arr, first, last, median); quickSortRec(arr, first, pivotIndex - 1, median); quickSortRec(arr, pivotIndex + 1, last, median); } }
void Sorts<T>::quickSortRec(T arr[], int first, int last, bool median) { if(first < last) { int k = partition(arr, first, last, median); quickSortRec(arr, first, k , median); quickSortRec(arr, k + 1, last, median); } }
void Sorts<T>::quickSortRec(T arr[], int first, int last, bool median){ if(median && ((last+1)<3)){//base case, amended for use with median selectionSort(arr, (last+1)); return; } if(first<last){ int pivot = partition(arr, first, last, median); quickSortRec(arr, first, (pivot-1), median); quickSortRec(arr, (pivot+1), last, median); return; } }//recursive==Rec?
void quickSort(int array[], unsigned int length) { if (array == NULL || length < 2) return; quickSortRec(array, 0, length - 1); }
void Sorts<T>::quickSort(T arr[], int size) { bool m = false; quickSortRec(arr, 0, (size - 1), m); }
void Sorts<T>::quickSortMedian(T arr[], int size) { bool median = true; quickSortRec(arr,0,size-1,median); assert( Sorts<T>::isSorted(arr, size) ); }
void Sorts<T>::quickSortMedian(T arr[], int size){ quickSortRec(arr, 0, size-1, true); }
void Sorts<T>::quickSort(T arr[], int size){ quickSortRec(arr, 0, size-1, false); }
void Sorts<T>::quickSortWithMedian(T arr[], int size) { bool m = true; quickSortRec(arr, 0, (size -1), m); }