快速排序
插入排序
shell排序
堆排序
归并排序
public class Sort {
public void quickSort(int[] a ,int low ,int high){
int pivotPos = partion(a,low,high);
if(low<high){
quickSort(a,low,pivotPos-1);
quickSort(a,pivotPos+1,high);
}
for(int b:a){
System.out.println(b+" ");
}
}
public int partion( int[] a,int low ,int high){
int pivotPos = low;
int pivot = a[low];
for(int i=low;low<high;low++){
if(a[i]<pivot){
pivotPos++;
if(pivotPos!=i){
swap(a,pivotPos,i ) ;
}
}
}
a[low] = a[pivotPos];
a[pivotPos] = pivot;
return pivotPos;
}
public void swap(int a[],int b,int c){
int temp;
temp = a[b];
a[b] = a[c];
a[c] = temp;
}
public static void main(String[] args){
new Sort().quickSort(new int[]{2,3,1,4,6,8,9,5}, 0, 7);
}
}
插入排序
整理中
shell排序
整理中
堆排序
整理中
归并排序
整理中