class Test
{
public static void main (String[] args)
{
int[] a = {35,4,59,26,2,63};
for(int i=0;i<a.length;i++)
{
System.out.print(a[i]+" ");}
System.out.println();
quicksort(a,0,a.length-1);
for(int i=0;i<a.length;i++){
System.out.print(a[i]+" ");}
}
public static void quicksort( int[] v, int left, int right)
{
if(left < right){
int key = v[left];
int low = left;
int high = right;
while(low < high){
while(low < high && v[high] > key){
high--;
}
v[low] = v[high];
while(low < high && v[low] < key){
low++;
}
v[high] = v[low];
}
v[low] = key;
quicksort(v,left,low-1);
quicksort(v,low+1,right);
}
}
} |
|