|
4 | 4 |
|
5 | 5 | # 经典排序算法 |
6 | 6 |
|
7 | | -- [冒泡排序]() (待续) |
8 | | -- [选择排序]()(待续) |
9 | | -- [插入排序]()(待续) |
10 | | -- [归并排序](https://github.com/coderbruis/AlgorithmsInJava/blob/master/notes/algorithms/%E5%BD%92%E5%B9%B6%E6%8E%92%E5%BA%8F%E7%AE%97%E6%B3%95.md) 【更新中】 |
11 | | -- [快速排序]()(待续) |
12 | | -- [希尔排序]()(待续) |
13 | | -- [桶排序]() (待续) |
14 | | -- [基数排序]()(待续) |
15 | | -- [堆排序](https://github.com/coderbruis/AlgorithmsInJava/blob/master/notes/algorithms/%E5%A0%86%E6%8E%92%E5%BA%8F%E7%AE%97%E6%B3%95.md) 【更新中】 |
| 7 | +- [冒泡排序](https://github.com/coderbruis/AlgorithmsInJava/blob/master/notes/algorithms/%E5%86%92%E6%B3%A1%E6%8E%92%E5%BA%8F%E7%AE%97%E6%B3%95.md) |
| 8 | +- [选择排序](https://github.com/coderbruis/AlgorithmsInJava/blob/master/notes/algorithms/%E9%80%89%E6%8B%A9%E6%8E%92%E5%BA%8F%E7%AE%97%E6%B3%95.md) |
| 9 | +- [插入排序](https://github.com/coderbruis/AlgorithmsInJava/blob/master/notes/algorithms/%E6%8F%92%E5%85%A5%E6%8E%92%E5%BA%8F%E7%AE%97%E6%B3%95.md) |
| 10 | +- [归并排序](https://github.com/coderbruis/AlgorithmsInJava/blob/master/notes/algorithms/%E5%BD%92%E5%B9%B6%E6%8E%92%E5%BA%8F%E7%AE%97%E6%B3%95.md) |
| 11 | +- [快速排序](https://github.com/coderbruis/AlgorithmsInJava/blob/master/notes/algorithms/%E5%BF%AB%E9%80%9F%E6%8E%92%E5%BA%8F%E7%AE%97%E6%B3%95.md) |
| 12 | +- [希尔排序](https://github.com/coderbruis/AlgorithmsInJava/blob/master/notes/algorithms/%E5%B8%8C%E5%B0%94%E6%8E%92%E5%BA%8F%E7%AE%97%E6%B3%95.md) |
| 13 | +- [桶排序](https://github.com/coderbruis/AlgorithmsInJava/blob/master/notes/algorithms/%E6%A1%B6%E6%8E%92%E5%BA%8F%E7%AE%97%E6%B3%95.md) |
| 14 | +- [基数排序](https://github.com/coderbruis/AlgorithmsInJava/blob/master/notes/algorithms/%E5%9F%BA%E6%95%B0%E6%8E%92%E5%BA%8F%E7%AE%97%E6%B3%95.md) |
| 15 | +- [堆排序](https://github.com/coderbruis/AlgorithmsInJava/blob/master/notes/algorithms/%E5%A0%86%E6%8E%92%E5%BA%8F%E7%AE%97%E6%B3%95.md) |
16 | 16 |
|
17 | 17 | ## 排序算法总结 |
18 | 18 |
|
|
29 | 29 | | 希尔排序 | O(nlogn) | O(1) | | | | 不稳定 | |
30 | 30 | | 堆排序 | O(nlogn) | O(1) | | | | 不稳定 | |
31 | 31 |
|
32 | | -注意这里总结的都是平均时间复杂度,例如插入排序,如果是有序的数组,则时间复杂度会退化成O(n)。而快速排序,对于每次选择的p位置都是末尾位置,则会退化成时间复杂度为O(n^2)(通过让p的位置随机来解决这个问题)。 |
| 32 | +注意这里总结的都是平均时间复杂度。 |
| 33 | + |
| 34 | +例如插入排序,如果是有序的数组,则时间复杂度会退化成O(n)。而快速排序,对于每次选择的p位置都是末尾位置,则会退化成时间复杂度为O(n^2)(通过让p的位置随机来解决这个问题)。 |
33 | 35 | 对于归并排序、快速排序、堆排序这三个O(nlogn)的排序来说,时间复杂度是有常数级别的区别的,但是快速排序是相对更快的一种排序。 |
34 | 36 |
|
35 | 37 | 这里还需要注意的是,对于插入排序、快速排序、堆排序来说,都是原地排序的,即不需要额外的空间;而归并排序则是非原地排序,需要借助额外空间。 |
36 | 38 |
|
37 | 39 | > 排序算法的稳定性:对于相等的元素,在排序后,原来靠前的元素依然靠前,相等元素的相对位置没有发生改变。 |
38 | 40 | |
39 | | -> 除非面试题特别说明,否则认为要排序的数据范围是均匀分布的。 |
| 41 | +> 对于算法面试来说,除非面试题特别说明,否则认为要排序的数据范围是均匀分布的。 |
40 | 42 | |
41 | 43 | > 快速排序之所以叫快速排序,并不代表它比堆排序和归并排序优良。在最好情况下,它的渐进复杂度与 堆排序和归并排序是相同的。知识快速排序的常量系数比较小而已。 |
42 | 44 | |
43 | 45 | > 类库上提供的排序,并不是某一种算法的实现,而是综合了多种排序的综合排序。当数组比较小时,使用插入排序;当数组较大时,选择快速排序或其他的O(nlogn)的排序。 |
44 | 46 | |
45 | 47 | # 经典算法 |
46 | 48 |
|
47 | | -- [KMP算法]()(待续) |
48 | | -- [马拉车算法]()(待续) |
49 | | -- [Prim算法]()(待续) |
50 | | -- [Krusk]() (待续) |
51 | | -- [Dijkstra算法]() (待续) |
52 | | -- [Bellman-Ford算法]() (待续) |
| 49 | + |
| 50 | +KMP算法 |
| 51 | +马拉车算法 |
| 52 | +Prim算法 |
| 53 | +Krusk算法 |
| 54 | +Dijkstra算法 |
| 55 | +Bellman-Ford算法 |
53 | 56 |
|
54 | 57 | # 经典数据结构 |
55 | 58 | |
56 | | -- [数组]() (待续) |
57 | | -- [栈和队列]()(待续) |
58 | | -- [链表]()(待续) |
59 | | -- [二分搜索树]()(待续) |
60 | | -- [集合和映射]()(待续) |
| 59 | +- 数组 |
| 60 | +- 栈和队列 |
| 61 | +- 链表 |
| 62 | +- 二分搜索树 |
| 63 | +- 集合和映射 |
61 | 64 | - [堆和优先队列](https://github.com/coderbruis/AlgorithmsInJava/blob/master/notes/datastructures/%E5%A0%86%E5%92%8C%E4%BC%98%E5%85%88%E9%98%9F%E5%88%97.md) 【更新中】 |
62 | | -- [线段树]() (待续) |
63 | | -- [Trie树]() (待续) |
64 | | -- [并查集]()(待续) |
| 65 | +- 线段树 |
| 66 | +- Trie树 |
| 67 | +- 并查集 |
65 | 68 | - [AVL树](https://github.com/coderbruis/AlgorithmsInJava/blob/master/notes/datastructures/AVL%E6%A0%91.md)【更新中】 |
66 | | -- [红黑树]() (待续) |
67 | | -- [哈希表]()(待续) |
| 69 | +- 红黑树 |
| 70 | +- 哈希表 |
| 71 | + |
| 72 | +==================== 持续更新 =================== |
68 | 73 |
|
69 | 74 | # leetcode专区 |
70 | 75 |
|
|
0 commit comments