int randomized_partition(int*a,int p,int r)
{
int i=rand()%(r-p+1)+p; //get a random num from p to r
swap(a[i],a[r]); //get random pivotint key=a[r];
int m=p-1;
for(int j=p;j<r;j++)
{
if(a[j]<key)
{
m+=1;
swap(a[j],a[m]);
}
}
swap(a[m+1],a[r]);
return m+1;
}