Skip to content

Commit c84b30c

Browse files
committed
Fix recursive calls in quick_fast_sort
1 parent ab1966f commit c84b30c

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

quicksort.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,17 @@ void quick_fast_sort(data array[], int len) {
2424
if (len > 1) {
2525
int pivot_index = rand()%(len-1); // choose pivot
2626
int pivot_new_index = partition_fast(array, len, pivot_index); // partition the array and get the new pivot position
27-
quick_sort(array, pivot_new_index); // quick sort the first part
28-
quick_sort(array+pivot_new_index+1, len-pivot_new_index-1); // quick sort the second part
27+
quick_fast_sort(array, pivot_new_index); // quick sort the first part
28+
quick_fast_sort(array+pivot_new_index+1, len-pivot_new_index-1); // quick sort the second part
2929
}
3030
}
3131

3232
void quick_fast_sort_debug(data array[], int len, STAT *stat) {
3333
if (len > 1) {
3434
int pivot_index = rand()%(len-1); // choose pivot
3535
int pivot_new_index = partition_fast_debug(array, len, pivot_index, stat); // partition the array and get the new pivot position
36-
quick_sort_debug(array, pivot_new_index, stat); // quick sort the first part
37-
quick_sort_debug(array+pivot_new_index+1, len-pivot_new_index-1, stat); // quick sort the second part
36+
quick_fast_sort_debug(array, pivot_new_index, stat); // quick sort the first part
37+
quick_fast_sort_debug(array+pivot_new_index+1, len-pivot_new_index-1, stat); // quick sort the second part
3838
stat->recc += 2;
3939
}
4040
}

0 commit comments

Comments
 (0)