快速排序
快速排序的简单实现
public class QuickSort { public static void main(String[] args) { int[] arr = {10, 11, 5, 0}; quickSort(arr, 0, arr.length - 1); Zutil.print(arr); } private static void quickSort(int[] arr, int st, int end) { if (end <= st) { return; } int index = st; int count = 0; int length = end - st; int limit = end; while (count < length) { if (arr[index + 1] < arr[index]) { Zutil.swap(arr, index, index + 1); index++; } else if (arr[index + 1] > arr[index]) { Zutil.swap(arr, index + 1, limit); limit--; } count++; } quickSort(arr, st, index - 1); quickSort(arr, index + 1, end); } }