Randomized quicksort

In the quicksort lecture I have been taught to take middle item as pivot, I am confused about randomized quicksort.

import java.util.*;
public class Main
{
static void quick(long []a,int low,int high)
{
int left=0,right=a.length-1,pivot=(low+high)/2;

    if (low>=high)
    {
        return;
    }
    while(left<=right)
    {
        while(a[left]<a[pivot])
        left++;
        
        while(a[right]>a[pivot])
        right--;
        
        if(left<=right)
        {
            long temp=a[left];
            a[left]=a[right];
            a[right]=temp;
            left++; 
            right--;
        }
    }
    quick(a,low,right);
    quick(a,left,high);
}
public static void main(String[] args) 
{
    Scanner sc=new Scanner(System.in);
    int size=sc.nextInt();
    long arr[]=new long[size];
    for(int i=0;i<size;i++)
    arr[i]=sc.nextInt();
	quick(arr,0,arr.length-1);
	for(long i:arr)
	{
	    System.out.print(i+" ");
	}
}

}

I tried this…it has gone through only 1 test case

@tishachhabra2702_8fc5a68a2e295e35 in randomized quick sort you have to take a pivot at a random index and that random number can be generated using Random Class of java Like shown in below link :

import java.lang.Math; import java.util.; public class Main { static void quick(long []a,int low,int high) { Random r=new Random(); int left=0,right=a.length-1,pivot=(int)Math.random()(high-low+1)+low; if (low>=high) { return; } while(left<=right) { while(a[left]<a[pivot]) left++; while(a[right]>a[pivot]) right–; if(left<=right) { long temp=a[left]; a[left]=a[right]; a[right]=temp; left++; right–; } } quick(a,low,right); quick(a,left,high); } public static void main(String[] args) { Scanner sc=new Scanner(System.in); int size=sc.nextInt(); long arr[]=new long[size]; for(int i=0;i<size;i++) arr[i]=sc.nextInt(); quick(arr,0,arr.length-1); for(long i:arr) { System.out.print(i+" "); } } }

This is also not working

@tishachhabra2702_8fc5a68a2e295e35 Can you send the code in readable form? Try adding triple ‘’’ before and after the code to specify to the editor that it is a code or Try using your laptop to send the code.

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.