File tree 1 file changed +36
-0
lines changed
1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ title : 八大排序算法复杂度
3
+ toc : false
4
+ date : 2017-04-20 17:49:14
5
+ tags : [算法]
6
+ ---
7
+
8
+ | 排序方法 | 平均时间 | 最坏时间 | 辅助空间 | 稳定性 |
9
+ | :----: | :-----------: | :-----------: | :-----------: | :--: |
10
+ | 冒泡排序 | $O(n^2)$ | $O(n^2)$ | $O(1)$ | 稳定 |
11
+ | 简单选择排序 | $O(n^2)$ | $O(n^2)$ | $O(1)$ | 稳定 |
12
+ | 直接插入排序 | $O(n^2)$ | $O(n^2)$ | $O(1)$ | 稳定 |
13
+ | 希尔排序 | $O(n \log n)$ | $O(n^2)$ | $O(1)$ | 不稳定 |
14
+ | 堆排序 | $O(n \log n)$ | $O(n \log n)$ | $O(1)$ | 不稳定 |
15
+ | 并归排序 | $O(n \log n)$ | $O(n \log n)$ | $O(n)$ | 稳定 |
16
+ | 快速排序 | $O(n \log n)$ | $O(n^2)$ | $O(n \log n)$ | 不稳定 |
17
+ | 基数排序 | $O(d(n+r))$ | $O(d(n+r))$ | $O(n)$ | 稳定 |
18
+
19
+ 注:基数排序中,d 为位数,r 为基数,n 为原数组个数。
20
+
21
+
22
+
23
+
24
+
25
+
26
+
27
+ ## 参考资料
28
+ > - 大话数据结构 | 程杰
29
+ > - [ Sorting Algorithms Animations] ( https://www.toptal.com/developers/sorting-algorithms/ )
30
+ > - [ 冒泡排序 | Wikipedia] ( https://zh.wikipedia.org/wiki/冒泡排序 )
31
+ > - [ 选择排序 | Wikipedia] ( https://zh.wikipedia.org/wiki/选择排序 )
32
+ > - [ 快速排序 | Wikipedia] ( https://zh.wikipedia.org/wiki/快速排序 )
33
+ > - [ 堆排序| Wikipedia] ( https://zh.wikipedia.org/wiki/堆排序 )
34
+ > - [ 希尔排序 | Wikipedia] ( https://zh.wikipedia.org/wiki/希尔排序 )
35
+ > - [ 归并排序 | Wikipedia] ( https://zh.wikipedia.org/wiki/归并排序 )
36
+ > - [ 维基百科上的算法和数据结构链接很强大 | http://blog.csdn.net/21aspnet/article/details/7199579 ] ( http://blog.csdn.net/21aspnet/article/details/7199579 )
You can’t perform that action at this time.
0 commit comments