My algorithm is not working.
Input -> int[] array = {40,20,90,30,70};
Output -> {20,40,70,30,90};
Array is not correctly sorted.
I have soend lot of hours but still not able to ubdertand where is the problem.
public static void quickSort(int[] array, int low, int high){
if(low >= high) {
return;
}
int left = low;
int right = high;
int pivotPoint = (low + high)/2;
while(left<=right){
while(array[left]<array[pivotPoint]){
++left;
}
while(array[right]>array[pivotPoint]){
--right;
}
if(left<=right){
int temp = array[left];
array[left] = array[right];
array[right] = temp;
}
++left;
--right;
}
quickSort(array,low,right);
quickSort(array,left,high);
}