We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 018e7a2 commit b0aa4b1Copy full SHA for b0aa4b1
docs/Quicksort.md
@@ -48,7 +48,7 @@ $$
48
当我们选取的枢纽每次都是**最大元素**时,就是**最差**情况,待排序的序列为正序或者逆序,每次划分只得到一个比上一次划分少一个记录的子序列,注意另一个为空。如果递归树画出来,它就是一棵斜树。此时需要执行$n‐1$次递归调用,且第 $i$ 次划分需要经过 $n‐i$ 次关键字的比较才能找到第 $i$ 个记录,是枢轴的位置,因此比较次数为:
49
50
$$
51
-\sum_{i=1}^{n-1} = (n-1) + (n-2) + + ... + 1 = \frac{n(n-1)}{2}
+\sum_{i=1}^{n-1} = (n-1) + (n-2) + ... + 1 = \frac{n(n-1)}{2}
52
53
54
于是时间复杂度为:$O(n^2)$。
0 commit comments