排序五:快速排序
快速排序
public class Five { static int[] arr; public static void quikSort(int[] arr) { recurQuikSort(0,arr.length-1); } /** * @param i 数组最小下标 * @param j 数组最大下标 * */ private static void recurQuikSort(int low, int high) { if(low > high) { return; }else { int pivot = arr[low]; //基准 int partition = partition(low,high,pivot); } } private static int partition(int low, int high, int pivot) { while(low < high) { while(low < high && arr[high] >= pivot) { high--; } swap(low,high);//交换 while(low <high && arr[low] <= pivot) { low++; } swap(low,high);//交换 } return 0; } private static void swap(int low, int high) { int temp = arr[low]; arr[low] = arr[high]; arr[high] = temp; } }
天助自助者