I tried to submit quicksort question and I am submitting the same code shown by garima mam in video. but its giving wrong answer. I am providing the code below. The question demands randomised quicksort but in that case, it will be giving me TLE and not wrong answer.
Please check once.
public static void Quicksort(int[] arr, int low, int high){
if(low>=high) return;
int pivot = (low+high)/2;
int i = low;
int j = high;
while(i<=j){
while(arr[i]<arr[pivot]) i++;
while(arr[j]>arr[pivot]) j–;
if(i<=j){
int temp = arr[i];
arr[i] = arr[j];
arr[j] = temp;
i++;
j–;
}
}
Quicksort(arr, low, j);
Quicksort(arr, i, high);
}