Importjava.util.Arrays; Public classQuickSort {//three take the Chinese method. Take out the position of the little one. Public Static intGetpivotpos (int[] A,intLowintHigh ) { intMid= (Low+high)/2; intpos=Low ; intminpos=Low ; intmaxpos=Low ; if(A[mid]<a[minpos]) minpos=mid; if(A[high]<a[minpos]) minpos=High ; if(A[mid]>a[maxpos]) maxpos=mid; if(A[high]>a[maxpos]) maxpos=High ; if(Low!=minpos&&low!=maxpos) pos=Low ; if(Mid!=minpos&&mid!=maxpos) pos=mid; if(High!=minpos&&high!=maxpos) pos=High ; returnPOS; } //Divide, take out the pivot position Public Static intPartitionint[] A,intLowintHigh ) { intpivotpos=Getpivotpos (A,low,high); intpivot=A[pivotpos]; inttemp=pivot; A[pivotpos]=A[low]; A[low]=temp; while(low<High ) { while(Low; A[low]=A[high]; while(Low; A[high]=A[low]; } A[low]=pivot; returnLow ; } //Quick Line Public Static voidQuickSort (int[] A,intLowintHigh ) { if(low<High ) { intpivotpos=partition (A,low,high); QuickSort (A,low,pivotpos-1); QuickSort (A,pivotpos+1, high); } } //Heavy-duty quick-row Public Static voidQuickSort (int[] a) {if(a.length==0) return; intLow=0; intHigh=a.length-1; QuickSort (A,low,high); } Public Static voidMain (string[] args) {int[] a= {12,32,24,99,54,76,48}; QuickSort (a); System.out.println (Arrays.tostring (a)); }}
Fast row +java Implementation