I'm stuck on this question for a while now and can't think of anything anymore so i need someones help to point me to right direction.
Question is :
After doing some research i figured out what is exactly median of three alg using quick sort and wrote the following code :Create A modified recursive quick sort method that uses the median-of-three method to choose the pivot. Also, the base cases for this modified method are lists of 10 elements or less. Your modified method should sort a list of 10 elements or less directly (i.e., with no recursion) using an iterative algorithm of your choosing.
public static void mQuickSort(int numbers[],int low,int high) { if (high <= 10){ int mid,replace,lowCount,highCount; lowCount = low; mid = (high + low) /2; highCount = mid + 1; if (numbers[mid] < numbers[low]) { replace = numbers[low]; numbers[low] = numbers[mid]; numbers[mid] = replace; } if (numbers[high] < numbers[low]) { replace = numbers[low]; numbers[low] = numbers[high]; numbers[high] = replace; } if (numbers[mid] < numbers[low]) { replace = numbers[mid]; numbers[mid] = numbers[high]; numbers[high] = replace; } replace = numbers[mid]; numbers[mid] = numbers[high-1]; numbers[high-1] = replace; }
I have no idea what to do next. I have created code for quick sort using recursion and it seems to be working fine but im not totally sure what is this question ask me for. Could some one please point me to right direction. Thank you