Beispiel #1
0
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
}
Beispiel #2
0
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);
    }
}
Beispiel #3
0
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);

    }
}
Beispiel #4
0
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?
Beispiel #5
0
void quickSort(int array[], unsigned int length)
{
	if (array == NULL || length < 2)
		return;

	quickSortRec(array, 0, length - 1);
}
Beispiel #6
0
void Sorts<T>::quickSort(T arr[], int size)
{
    bool m = false;
    quickSortRec(arr, 0, (size - 1), m);


}
Beispiel #7
0
void Sorts<T>::quickSortMedian(T arr[], int size)
{
    bool median = true;

    quickSortRec(arr,0,size-1,median);

    assert( Sorts<T>::isSorted(arr, size) );
}
Beispiel #8
0
void Sorts<T>::quickSortMedian(T arr[], int size){

	quickSortRec(arr, 0, size-1, true);

}
Beispiel #9
0
void Sorts<T>::quickSort(T arr[], int size){

	quickSortRec(arr, 0, size-1, false);	

}
Beispiel #10
0
void Sorts<T>::quickSortWithMedian(T arr[], int size)
{
    bool m = true;
    quickSortRec(arr, 0, (size -1), m);

}