Repository navigation
Expand file tree
/
Copy pathindex.html
More file actions
419 lines (196 loc) · 15.5 KB
/
Copy pathindex.html
File metadata and controls
419 lines (196 loc) · 15.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
<!DOCTYPE HTML>
<html lang="" >
<head>
<meta charset="UTF-8">
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<title>Introduction · 排序算法</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="description" content="">
<meta name="generator" content="GitBook 3.2.3">
<meta name="author" content="崔安兵">
<link rel="stylesheet" href="gitbook/style.css">
<link rel="stylesheet" href="gitbook/gitbook-plugin-chapter-fold/chapter-fold.css">
<link rel="stylesheet" href="gitbook/gitbook-plugin-search-plus/search.css">
<link rel="stylesheet" href="gitbook/gitbook-plugin-splitter/splitter.css">
<link rel="stylesheet" href="gitbook/gitbook-plugin-page-toc-button/plugin.css">
<link rel="stylesheet" href="gitbook/gitbook-plugin-flexible-alerts/style.css">
<link rel="stylesheet" href="gitbook/gitbook-plugin-katex/katex.min.css">
<link rel="stylesheet" href="gitbook/gitbook-plugin-tbfed-pagefooter/footer.css">
<link rel="stylesheet" href="gitbook/gitbook-plugin-highlight/website.css">
<link rel="stylesheet" href="gitbook/gitbook-plugin-fontsettings/website.css">
<link rel="stylesheet" href="res/mystyle.css">
<meta name="HandheldFriendly" content="true"/>
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<link rel="apple-touch-icon-precomposed" sizes="152x152" href="gitbook/images/apple-touch-icon-precomposed-152.png">
<link rel="shortcut icon" href="gitbook/images/favicon.ico" type="image/x-icon">
<link rel="next" href="1.bubbleSort.html" />
</head>
<body>
<div class="book">
<div class="book-summary">
<div id="book-search-input" role="search">
<input type="text" placeholder="Type to search" />
</div>
<nav role="navigation">
<ul class="summary">
<li class="chapter active" data-level="1.1" data-path="./">
<a href="./">
Introduction
</a>
</li>
<li class="chapter " data-level="1.2" data-path="1.bubbleSort.html">
<a href="1.bubbleSort.html">
冒泡排序
</a>
</li>
<li class="chapter " data-level="1.3" data-path="2.selectionSort.html">
<a href="2.selectionSort.html">
选择排序
</a>
</li>
<li class="chapter " data-level="1.4" data-path="3.insertionSort.html">
<a href="3.insertionSort.html">
插入排序
</a>
</li>
<li class="chapter " data-level="1.5" data-path="4.shellSort.html">
<a href="4.shellSort.html">
希尔排序
</a>
</li>
<li class="chapter " data-level="1.6" data-path="5.mergeSort.html">
<a href="5.mergeSort.html">
归并排序
</a>
</li>
<li class="chapter " data-level="1.7" data-path="6.quickSort.html">
<a href="6.quickSort.html">
快速排序
</a>
</li>
<li class="chapter " data-level="1.8" data-path="7.heapSort.html">
<a href="7.heapSort.html">
堆排序
</a>
</li>
<li class="chapter " data-level="1.9" data-path="8.countingSort.html">
<a href="8.countingSort.html">
计数排序
</a>
</li>
<li class="chapter " data-level="1.10" data-path="9.bucketSort.html">
<a href="9.bucketSort.html">
桶排序
</a>
</li>
<li class="chapter " data-level="1.11" data-path="10.radixSort.html">
<a href="10.radixSort.html">
基数排序
</a>
</li>
<li class="divider"></li>
<li>
<a href="https://www.gitbook.com" target="blank" class="gitbook-link">
Published with GitBook
</a>
</li>
</ul>
</nav>
</div>
<div class="book-body">
<div class="body-inner">
<div class="book-header" role="navigation">
<!-- Title -->
<h1>
<i class="fa fa-circle-o-notch fa-spin"></i>
<a href="." >Introduction</a>
</h1>
</div>
<div class="page-wrapper" tabindex="-1" role="main">
<div class="page-inner">
<div class="search-plus" id="book-search-results">
<div class="search-noresults">
<section class="normal markdown-section">
<h1 id="十大经典排序算法">十大经典排序算法</h1>
<p>排序算法是《数据结构与算法》中最基本的算法之一。</p>
<p>排序算法可以分为内部排序和外部排序,内部排序是数据记录在内存中进行排序,而外部排序是因排序的数据很大,一次不能容纳全部的排序记录,在排序过程中需要访问外存。常见的内部排序算法有:<strong>插入排序、希尔排序、选择排序、冒泡排序、归并排序、快速排序、堆排序、基数排序</strong>等。用一张图概括:</p>
<p><img src="res/sort.png" alt="十大经典排序算法 概览截图"></p>
<p><strong>关于时间复杂度</strong>:</p>
<ol>
<li>平方阶 (O(n2)) 排序
各类简单排序:直接插入、直接选择和冒泡排序。</li>
<li>线性对数阶 (O(nlog2n)) 排序
快速排序、堆排序和归并排序;</li>
<li>O(n1+§)) 排序,§ 是介于 0 和 1 之间的常数。
希尔排序</li>
<li>线性阶 (O(n)) 排序
基数排序,此外还有桶、箱排序。</li>
</ol>
<p><strong>关于稳定性</strong>:</p>
<p>稳定的排序算法:冒泡排序、插入排序、归并排序和基数排序。</p>
<p>不是稳定的排序算法:选择排序、快速排序、希尔排序、堆排序。</p>
<p><strong>名词解释</strong>:</p>
<p><strong>n</strong>:数据规模</p>
<p><strong>k</strong>:“桶”的个数</p>
<p><strong>In-place</strong>:占用常数内存,不占用额外内存</p>
<p><strong>Out-place</strong>:占用额外内存</p>
<p><strong>稳定性</strong>:排序后 2 个相等键值的顺序和排序之前它们的顺序相同</p>
<hr>
<p><strong>GitBook 内容大纲</strong></p>
<ol>
<li><a href="1.bubbleSort.html">冒泡排序</a></li>
<li><a href="2.selectionSort.html">选择排序</a></li>
<li><a href="3.insertionSort.html">插入排序</a></li>
<li><a href="4.shellSort.html">希尔排序</a></li>
<li><a href="5.mergeSort.html">归并排序</a></li>
<li><a href="6.quickSort.html">快速排序</a></li>
<li><a href="7.heapSort.html">堆排序</a></li>
<li><a href="8.countingSort.html">计数排序</a></li>
<li><a href="9.bucketSort.html">桶排序</a></li>
<li><a href="10.radixSort.html">基数排序</a></li>
</ol>
<hr>
<p>本书内容几乎完全来源于网络。</p>
<footer class="page-footer"><span class="copyright">Copyright © 崔安兵 2019 all right reserved,powered by Gitbook</span><span class="footer-modification">该文件修订时间:
2019-10-25 16:29:53
</span></footer>
</section>
</div>
<div class="search-results">
<div class="has-results">
<h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
<ul class="search-results-list"></ul>
</div>
<div class="no-results">
<h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
</div>
</div>
</div>
</div>
</div>
</div>
<a href="1.bubbleSort.html" class="navigation navigation-next navigation-unique" aria-label="Next page: 冒泡排序">
<i class="fa fa-angle-right"></i>
</a>
</div>
<script>
var gitbook = gitbook || [];
gitbook.push(function() {
gitbook.page.hasChanged({"page":{"title":"Introduction","level":"1.1","depth":1,"next":{"title":"冒泡排序","level":"1.2","depth":1,"path":"1.bubbleSort.md","ref":"1.bubbleSort.md","articles":[]},"dir":"ltr"},"config":{"plugins":["chapter-fold","-lunr","-search","search-plus","splitter","page-toc-button","flexible-alerts","katex","tbfed-pagefooter"],"styles":{"website":"./res/mystyle.css"},"pluginsConfig":{"tbfed-pagefooter":{"copyright":"Copyright © 崔安兵 2019","modify_label":"该文件修订时间:","modify_format":"YYYY-MM-DD HH:mm:ss"},"chapter-fold":{},"splitter":{},"katex":{},"fontsettings":{"theme":"white","family":"sans","size":2},"highlight":{},"page-toc-button":{},"flexible-alerts":{"danger":{"className":"danger","icon":"fa fa-ban","label":"Attention"},"note":{"className":"info","icon":"fa fa-info-circle","label":"Note"},"style":"callout","tip":{"className":"tip","icon":"fa fa-lightbulb-o","label":"Tip"},"warning":{"className":"warning","icon":"fa fa-exclamation-triangle","label":"Warning"}},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false},"search-plus":{}},"theme":"default","author":"崔安兵","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"排序算法","gitbook":"*"},"file":{"path":"README.md","mtime":"2019-10-25T08:29:53.201Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2019-10-25T10:22:54.457Z"},"basePath":".","book":{"language":""}});
});
</script>
</div>
<script src="gitbook/gitbook.js"></script>
<script src="gitbook/theme.js"></script>
<script src="gitbook/gitbook-plugin-chapter-fold/chapter-fold.js"></script>
<script src="gitbook/gitbook-plugin-search-plus/jquery.mark.min.js"></script>
<script src="gitbook/gitbook-plugin-search-plus/search.js"></script>
<script src="gitbook/gitbook-plugin-splitter/splitter.js"></script>
<script src="gitbook/gitbook-plugin-page-toc-button/plugin.js"></script>
<script src="gitbook/gitbook-plugin-flexible-alerts/plugin.js"></script>
<script src="gitbook/gitbook-plugin-sharing/buttons.js"></script>
<script src="gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
</body>
</html>