快速排序java语言实现
/**
* 快速排序
*
*/
public class QuickSort {
public void quickSort(int[] array, int left, int right){
if(left>=right){
return;
}
int key =array[left];
int i= left;
int j= right;
while (j>i){
while (array[j]>=key && j>i){
j--;
}
array[i]=array[j];
while (array[i]<=key && j>i){
i++;
}
array[j]=array[i];
}
array[i]=key;
quickSort(array,left,i-1);
quickSort(array,j+1,right);
}
public static void main(String[] args) {
int[] a ={34,15,7,1,6,89,3,6};
QuickSort q =new QuickSort();
q.quickSort(a, 0, a.length - 1);
for(int b :a){
System.out.println(b);
}
}
}