Package com.javatest300;
public class Test039 {
public static void Main (string[] args) {//Quick sort
int a[]={2,3,8,10,5,1,8,78,35,12};
SYSTEM.OUT.PRINTLN ("---------before sorting");
for (int i = 0; i < a.length; i++) {
System.out.print (a[i]+ "");
}
System.out.println ();
SYSTEM.OUT.PRINTLN ("---------after sorting");
Quick_sort (A, 0, a.length-1);
for (int i = 0; i < a.length; i++) {
System.out.print (a[i]+ "");
}
System.out.println ();
}
public static void Quick_sort (int arr[],int start,int end) {
if (start<end) {//The case of course omitted (ARR==NULLEND-START+1<2), that is, the passed array is empty and only one element in the array
int privote=partition (arr,start,end);
Quick_sort (arr, start, privote-1);
Quick_sort (arr, privote+1, end);
}
}
public static int Partition (int. arr[],int Low,int High) {
int Tmp=arr[low];
while (Low
while (Low
high--;
}
Arr[low]=arr[high];
while (low
low++;
}
Arr[high]=arr[low];
}
arr[low]=tmp; return low;
}
}
Quick ordering of sorting algorithms (Java Implementation)