热门

最新

红包

立Flag

投票

同城

我的

发布
m0_67648503
m0_67648503
3 年前
truem0_67648503

求大神帮忙

CSDN App 扫码分享
分享
1
2
打赏
  • 复制链接
  • 举报
下一条:
java快速排序代码实现 long start = System.nanoTime(); sort(array, 0, array.length - 1); long end = System.nanoTime(); System.out.println(end - start); // 优化后 private static void sort(int[] array, int low, int high) { int i, j, index; if (low > high) { return; } i = low; // 哨兵i j = high; // 哨兵j index = array[i]; // 第一次排序的基准数 while (i < j) { // 从表的俩端往中间开始扫描 while (i < j && array[j] >= index) j--; if (i < j) array[i++] = array[j]; while (i < j && array[i] < index) i++; if (i < j) array[j--] = array[i]; } array[i] = index; sort(array, low, i - 1); sort(array, i + 1, high); }
立即登录