Skip to content

Commit b0aa4b1

Browse files
committed
renew Quicksort
1 parent 018e7a2 commit b0aa4b1

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

docs/Quicksort.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ $$
4848
当我们选取的枢纽每次都是**最大元素**时,就是**最差**情况,待排序的序列为正序或者逆序,每次划分只得到一个比上一次划分少一个记录的子序列,注意另一个为空。如果递归树画出来,它就是一棵斜树。此时需要执行$n‐1$次递归调用,且第 $i$ 次划分需要经过 $n‐i$ 次关键字的比较才能找到第 $i$ 个记录,是枢轴的位置,因此比较次数为:
4949

5050
$$
51-
\sum_{i=1}^{n-1} = (n-1) + (n-2) + + ... + 1 = \frac{n(n-1)}{2}
51+
\sum_{i=1}^{n-1} = (n-1) + (n-2) + ... + 1 = \frac{n(n-1)}{2}
5252
$$
5353

5454
于是时间复杂度为:$O(n^2)$。

0 commit comments

Comments
 (0)