Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit baa8805

Browse files
committed
快速排序
1 parent 8be6abd commit baa8805

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

app/src/main/java/com/zhxh/codeproj/sortcode/QuickSort.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,14 @@
1919
它需要遍历的次数就是二叉树的深度,而根据完全二叉树的定义,它的深度至少是lg(N+1)。因此,快速排序的遍历次数最少是lg(N+1)次。
2020
为什么最多是N次? 这个应该非常简单,还是将快速排序看作一棵二叉树,它的深度最大是N。因此,快读排序的遍历次数最多是N次
2121
22+
原始数据
23+
被操作数据
24+
已排序数据
25+
2226
*/
2327
public class QuickSort {
2428
public static void main(String[] args) {
25-
int[] a = {1, 3, -2, 5, 4, -3, 2, 6, -1, 1};
29+
int[] a = {1, 3, -2, 5, 4, -3, 2, 6, -1, 7, 1};
2630
System.out.println("排序前:" + Arrays.toString(a));
2731
quickSort(a, 0, a.length - 1);
2832
System.out.println("排序后:" + Arrays.toString(a));

0 commit comments

Comments
 (0)