-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
--- | ||
title: 八大排序算法复杂度 | ||
toc: false | ||
date: 2017-04-20 17:49:14 | ||
tags: [算法] | ||
--- | ||
|
||
| 排序方法 | 平均时间 | 最坏时间 | 辅助空间 | 稳定性 | | ||
| :----: | :-----------: | :-----------: | :-----------: | :--: | | ||
| 冒泡排序 | $O(n^2)$ | $O(n^2)$ | $O(1)$ | 稳定 | | ||
| 简单选择排序 | $O(n^2)$ | $O(n^2)$ | $O(1)$ | 稳定 | | ||
| 直接插入排序 | $O(n^2)$ | $O(n^2)$ | $O(1)$ | 稳定 | | ||
| 希尔排序 | $O(n \log n)$ | $O(n^2)$ | $O(1)$ | 不稳定 | | ||
| 堆排序 | $O(n \log n)$ | $O(n \log n)$ | $O(1)$ | 不稳定 | | ||
| 并归排序 | $O(n \log n)$ | $O(n \log n)$ | $O(n)$ | 稳定 | | ||
| 快速排序 | $O(n \log n)$ | $O(n^2)$ | $O(n \log n)$ | 不稳定 | | ||
| 基数排序 | $O(d(n+r))$ | $O(d(n+r))$ | $O(n)$ | 稳定 | | ||
|
||
注:基数排序中,d 为位数,r 为基数,n 为原数组个数。 | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
## 参考资料 | ||
> - 大话数据结构 | 程杰 | ||
> - [Sorting Algorithms Animations](https://www.toptal.com/developers/sorting-algorithms/) | ||
> - [冒泡排序 | Wikipedia](https://zh.wikipedia.org/wiki/冒泡排序) | ||
> - [选择排序 | Wikipedia](https://zh.wikipedia.org/wiki/选择排序) | ||
> - [快速排序 | Wikipedia](https://zh.wikipedia.org/wiki/快速排序) | ||
> - [堆排序| Wikipedia](https://zh.wikipedia.org/wiki/堆排序) | ||
> - [希尔排序 | Wikipedia](https://zh.wikipedia.org/wiki/希尔排序) | ||
> - [归并排序 | Wikipedia](https://zh.wikipedia.org/wiki/归并排序) | ||
> - [维基百科上的算法和数据结构链接很强大 | http://blog.csdn.net/21aspnet/article/details/7199579](http://blog.csdn.net/21aspnet/article/details/7199579) |