public class QuickSort {
public void quickSort2(int []A)
{
int p=0,r=A.length-1;
int loc=0;
if(p<r)
{
loc=partition2(A,p,r);
partition2(A,p,loc-1);
partition2(A,loc+1,r);
}
}
public int partition2(int []A,int p,int r)
{
//int loc=0;
int i=p-1;
int x=A[r];
for(int j=p;j<r;j++)
{
if(A[j]<x)
{
i=i+1;
int temp=A[j];
A[j]=A[i];
}
}
int temp=A[i+1];
A[i+1]=A[r];
A[r]=temp;
return i+1;
}
public int [] quickSort(int []arr)
{
int temp;
int i=0,j=arr.length-1;
temp=arr[0];
int low=0,high=arr.length-1;
while(i!=j)
{
}
return arr;
}
public void quick(int[] arr,int low ,int high)
{
int loc=0;
if(low<high)
{
loc=partition(arr,low ,high);
System.out.print(""+arr[loc]);
quick(arr,low,loc-1);
quick(arr,loc+1,high);
}
}
public int partition(int []arr,int low ,int high)
{
int piovat=arr[low];
while(low<high)
{
while(low<high&&arr[high]>piovat)high--;
arr[low]=arr[high];
while(low<high&&arr[low]<=piovat)low++;
arr[high]=arr[low];
}
arr[low]=piovat;
return low;
}
}