I am implementing quicksort in Java with the following requirements:
Use recursion (in your quicksort implementation) down to a stopping case of a partition of size k or smaller. For these partitions, use an insertion sort to finish.
I'm confused as to how to implement this or even what it is asking. Here is what I have for the normal quicksort. How could I modify this to meet the requirements?
public static void quick_srt(int array[],int low, int n){
int lo = low;
int hi = n;
if (lo >= n) {
return;
}
int mid = array[(lo + hi) / 2];
while (lo < hi) {
while (lo<hi && array[lo] < mid) {
lo++;
}
while (lo<hi && array[hi] > mid) {
hi--;
}
if (lo < hi) {
int T = array[lo];
array[lo] = array[hi];
array[hi] = T;
}
}
if (hi < lo) {
int T = hi;
hi = lo;
lo = T;
}
quick_srt(array, low, lo);
quick_srt(array, lo == low ? lo+1 : lo, n);
}