-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDataStructure.km
349 lines (349 loc) · 19.5 KB
/
DataStructure.km
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
{
"root": {
"data": {
"id": "cfrp6o0jygg0",
"created": 1637115991747,
"text": "Data Structure"
},
"children": [
{
"data": {
"id": "cfsivuwp2dc0",
"created": 1637199778042,
"text": "分类",
"expandState": "expand",
"layout_right_offset": {
"x": -136,
"y": 378
},
"layout_mind_offset": {
"x": -83,
"y": 2
}
},
"children": [
{
"data": {
"id": "cfrp87bj2g00",
"created": 1637116112133,
"text": "逻辑结构",
"layout_right_offset": {
"x": 4,
"y": 134
},
"expandState": "expand"
},
"children": [
{
"data": {
"id": "cfrp8apr5z40",
"created": 1637116119524,
"text": "树",
"layout_right_offset": {
"x": 29,
"y": 169
}
},
"children": [
{
"data": {
"id": "cfskf8sfw740",
"created": 1637204118289,
"text": "二叉树",
"note": "深度优先遍历:\n - 前序遍历(中左右)\n - 中序遍历(左中右)\n - 后序遍历(左右中)\n广度优先遍历:\n - 层序遍历",
"expandState": "expand"
},
"children": [
{
"data": {
"id": "cfskfaxeue00",
"created": 1637204122943,
"text": "满二叉树",
"expandState": "expand"
},
"children": []
},
{
"data": {
"id": "cfskfdrahi00",
"created": 1637204129103,
"text": "完全二叉树",
"note": "1、链表存储\n2、数组存储:\n - 父节点下标parent,左孩子节点下标2×parent + 1,右孩子节点下标2×parent + 2\n - 左孩子节点下标leftChild,左孩子节点下标(leftChild-1)/ 2"
},
"children": [
{
"data": {
"id": "cfskfq439xs0",
"created": 1637204155999,
"text": "二叉堆"
},
"children": [
{
"data": {
"id": "cfssuvz1dq80",
"created": 1637227913096,
"text": "最大堆",
"note": "最大堆的任何一个父节点的值,都大于或等于它左、右孩子节点的值。\n最大堆的堆顶(根节点)是整个堆中的最大元素。"
},
"children": [
{
"data": {
"id": "cfsszzrgq1k0",
"created": 1637228313166,
"text": "最大优先队列"
},
"children": []
}
]
},
{
"data": {
"id": "cfssuyar9s80",
"created": 1637227918158,
"text": "最小堆",
"note": "最小堆的任何一个父节点的值,都小于或等于它左、右孩子节点的值。\n最小堆的堆顶(根节点)是整个堆中的最小元素。"
},
"children": [
{
"data": {
"id": "cfst08ztpm80",
"created": 1637228333262,
"text": "最小优先队列"
},
"children": []
}
]
}
]
}
]
},
{
"data": {
"id": "cgh7ohzmpaw0",
"created": 1639707168080,
"text": "二叉搜索树(BST)",
"note": "BST 的完整定义如下:\n1、BST 中任意一个节点的左子树所有节点的值都小于该节点的值,右子树所有节点的值都大于该节点的值。\n2、BST 中任意一个节点的左右子树都是 BST。\n可用于二分搜索"
},
"children": []
}
]
}
]
},
{
"data": {
"id": "cfskemrwbdk0",
"created": 1637204070367,
"text": "栈",
"layout_right_offset": {
"x": 0,
"y": -50
}
},
"children": []
},
{
"data": {
"id": "cfskeq9b9000",
"created": 1637204077950,
"text": "队列",
"layout_right_offset": {
"x": 7,
"y": -56
}
},
"children": []
},
{
"data": {
"id": "cfskevlkm7c0",
"created": 1637204089575,
"text": "散列表"
},
"children": []
}
]
},
{
"data": {
"id": "cfrp7vfiuew0",
"created": 1637116086253,
"text": "物理结构",
"layout_right_offset": {
"x": -9,
"y": -294
}
},
"children": [
{
"data": {
"id": "cfsp5z08iv40",
"created": 1637217497265,
"text": "数组"
},
"children": [
{
"data": {
"id": "chdklj1kohk0",
"created": 1642993528324,
"text": "哈希表"
},
"children": []
},
{
"data": {
"id": "chdkb25625c0",
"created": 1642992707894,
"text": "二叉堆"
},
"children": []
}
]
},
{
"data": {
"id": "cfrp83tyevs0",
"created": 1637116104540,
"text": "链表"
},
"children": [
{
"data": {
"id": "chdklbt732w0",
"created": 1642993512580,
"text": "二叉树"
},
"children": []
}
]
}
]
},
{
"data": {
"id": "cfumf6ho0tc0",
"created": 1637412875417,
"text": "算法"
},
"children": [
{
"data": {
"id": "cfumfhdvpiw0",
"created": 1637412899133,
"text": "排序"
},
"children": [
{
"data": {
"id": "cfumfknt84g0",
"created": 1637412906264,
"text": "冒泡排序",
"note": "· 稳定排序(值相同的元素排序后位置不变)\n· 与后一位比大小和换位,需要循环array.length - 1轮\n· 优化:\n - 增加标记位isSorted标记数列有序,跳出大循环;\n - 增加lastExchangeIndex标记最后一次交换的位置;\n - 增加sortBorder标记无序数列的边界,每次比较到边界即可。"
},
"children": [
{
"data": {
"id": "cfunhevrswg0",
"created": 1637415871522,
"text": "鸡尾酒排序",
"note": "在冒泡排序基础上的优化,元素的比较和交换过程是双向的(一轮左到右,一轮右到左……)"
},
"children": []
}
]
},
{
"data": {
"id": "cfunrv06f1k0",
"created": 1637416690259,
"text": "快速排序",
"note": "不稳定排序\n使用分治法,每次挑选一个基准元素,比他大的移动到一边,比他小的移动到另一边。",
"layout_right_offset": {
"x": 3,
"y": -30
}
},
"children": [
{
"data": {
"id": "cfunuswo4ao0",
"created": 1637416920786,
"text": "双边循环",
"note": "每次(递归)一个pivot元素,一个left指针和一个right指针,指针元素无需变动时指针移动,需要变动时指针停止,俩指针指向的元素互换。最后俩指针重叠时,将基准元素pivot与指针元素交换。",
"layout_right_offset": {
"x": -1,
"y": -1
}
},
"children": []
},
{
"data": {
"id": "cfunuwf6zq80",
"created": 1637416928436,
"text": "单边循环",
"note": "每次(递归)一个pivot元素,一个mark指针。大循环遍历,元素大于pivot则继续,小于pivot则mark++,将元素与mark指向元素互换位置(mark像是边界线),循环玩之后,将pivot元素与mark元素互换。",
"layout_right_offset": {
"x": 0,
"y": -10
}
},
"children": []
}
]
},
{
"data": {
"id": "cfuoi5e0eds0",
"created": 1637418750332,
"text": "堆排序",
"layout_right_offset": {
"x": 1,
"y": -63
},
"note": "不稳定排序\n循环删除二叉堆堆顶元素,替换到二叉堆的末尾,调整堆产生新的堆顶,如此往复,最后二叉堆的层序遍历顺序即为所需的排序结果。"
},
"children": []
}
]
}
]
}
]
},
{
"data": {
"id": "cfsiw5dluvk0",
"created": 1637199800833,
"text": "特性",
"layout_right_offset": {
"x": -399,
"y": -362
}
},
"children": [
{
"data": {
"id": "cfsiwtdaq3s0",
"created": 1637199853057,
"text": "时间复杂度"
},
"children": []
},
{
"data": {
"id": "cfsiwzr4lcg0",
"created": 1637199866954,
"text": "空间复杂度"
},
"children": []
}
]
}
]
},
"template": "default",
"theme": "fresh-purple",
"version": "1.4.43"
}