Quick Sort plots:
--------------------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------------
=============================================================================================================== ===========
=============================================================================================================== ===========
Implementation of Java code:
1 Packagemain.test;2 3 Public classKssort {4 Public Static intPartition (int[] A,intPintr) {5 intx = a[r-1];6 inti = P-1;7 inttemp;8 for(intj = P; J <= R-1; J + +) {9 if(A[j-1] <=x) {Ten //Exchange (A[j-1],a[i-1]); Onei++; Atemp = A[j-1]; -A[J-1] = a[i-1]; -A[I-1] =temp; the } - } - //Exchange (A[r-1,a[i+1-1]); -temp = A[r-1]; +A[R-1] = a[i + 1-1]; -A[i + 1-1] =temp; + returni + 1; A } at - - Public Static voidQuickSort (int[] A,intPintR) { - if(p<R) { - intq=Partition (a,p,r); -QuickSort (a,p,q-1); inQuickSort (a,q+1, R); - } to } + - Static voidPrintint[] a) { the for(intvalues:a * ) { $System.out.print (values+ "| ");Panax Notoginseng } - } the + A Public Static voidMain (string[] args) { the int[] a={7,10,3,5,4,6,2,8,1,9}; +QuickSort (a,1,10); - print (a); $ $ - } - the -}View Code
Plot fast number Sorting method