Code given in video not working

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);
}

Please share your code using ide.codingblocks.com from the next time onwards as it is easier to debug it that way.

Your partitioning step is incorrect as your pivot value keeps on changing as it gets swapped by the i and j.
Instead of choosing the index as a pivot, do this
int mid = (low+high)/2;
int pivot = arr[mid];

Now you can do the partitioning like this:
while(arr[i]<pivot) i++;
while(arr[j]>pivot) j–;

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.