-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathatom.xml
427 lines (221 loc) · 87.6 KB
/
atom.xml
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
419
420
421
422
423
424
425
426
427
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title>WalUU</title>
<link href="https://walu.space/atom.xml" rel="self"/>
<link href="https://walu.space/"/>
<updated>2023-09-17T06:13:44.009Z</updated>
<id>https://walu.space/</id>
<author>
<name>walu</name>
</author>
<generator uri="https://hexo.io/">Hexo</generator>
<entry>
<title>女神异闻录4一周目</title>
<link href="https://walu.space/2023/09/17/%E5%A5%B3%E7%A5%9E%E5%BC%82%E9%97%BB%E5%BD%954%E4%B8%80%E5%91%A8%E7%9B%AE/"/>
<id>https://walu.space/2023/09/17/%E5%A5%B3%E7%A5%9E%E5%BC%82%E9%97%BB%E5%BD%954%E4%B8%80%E5%91%A8%E7%9B%AE/</id>
<published>2023-09-17T05:51:38.000Z</published>
<updated>2023-09-17T06:13:44.009Z</updated>
<content type="html"><![CDATA[<p>女神异闻录4一周目达成 <span id="more"></span><br>游戏讲了一个好故事,人格面具的合成机制也很有趣,但是战斗和刷社群等级有点无聊。为了跳过无聊部分,我是在开启了修改器的情况下玩的,30多小时完成了一周目的真结局。</p><p>二周目等于重新玩一遍一周目,或许会看到一些一周目忽略的细节,以后有时间慢慢玩吧,二周目可以合成伊邪那岐大神,但要等到中期解锁特殊合体之后才行,这也是玩二周目的动力。</p><p>如果时间不充裕,并且想知道这款游戏讲了什么故事,可以和我一样开启修改器玩或者直接去看衍生的番剧。</p>]]></content>
<summary type="html"><p>女神异闻录4一周目达成</p></summary>
<category term="娱乐" scheme="https://walu.space/categories/%E5%A8%B1%E4%B9%90/"/>
<category term="游戏" scheme="https://walu.space/tags/%E6%B8%B8%E6%88%8F/"/>
</entry>
<entry>
<title>下周我不看直播了</title>
<link href="https://walu.space/2023/09/10/%E4%B8%8B%E5%91%A8%E6%88%91%E4%B8%8D%E7%9C%8B%E7%9B%B4%E6%92%AD%E4%BA%86/"/>
<id>https://walu.space/2023/09/10/%E4%B8%8B%E5%91%A8%E6%88%91%E4%B8%8D%E7%9C%8B%E7%9B%B4%E6%92%AD%E4%BA%86/</id>
<published>2023-09-10T15:00:57.000Z</published>
<updated>2023-09-10T15:02:02.978Z</updated>
<content type="html"><![CDATA[<p>下周一周不看直播,多出的时间用来编程。 <span id="more"></span></p>]]></content>
<summary type="html"><p>下周一周不看直播,多出的时间用来编程。</p></summary>
<category term="生活" scheme="https://walu.space/tags/%E7%94%9F%E6%B4%BB/"/>
<category term="自制" scheme="https://walu.space/tags/%E8%87%AA%E5%88%B6/"/>
</entry>
<entry>
<title>济南相声大会真垃圾</title>
<link href="https://walu.space/2023/09/10/%E6%B5%8E%E5%8D%97%E7%9B%B8%E5%A3%B0%E5%A4%A7%E4%BC%9A%E7%9C%9F%E5%9E%83%E5%9C%BE/"/>
<id>https://walu.space/2023/09/10/%E6%B5%8E%E5%8D%97%E7%9B%B8%E5%A3%B0%E5%A4%A7%E4%BC%9A%E7%9C%9F%E5%9E%83%E5%9C%BE/</id>
<published>2023-09-10T14:52:42.000Z</published>
<updated>2023-09-16T04:18:37.640Z</updated>
<content type="html"><![CDATA[<p>今晚心血来潮,去济南相声大会听了会相声。只能说,票价一分钱我都嫌高。<span id="more"></span></p><ul><li>报幕不说相声的名字,这出于何种心理???</li><li>相声演员戴耳环(传统相声不允许这样)</li><li>相声演员前面的铺垫没有用上</li><li>逗哏和捧哏配合非常不默契</li><li>瞎改山东快书,改成了依托答辩</li><li>不同的节目之间瞎串,前面的铺垫感觉是节目A,后面又成了节目B,可能和上一条有关</li></ul><p>还是好生气,为什么有人说的这么垃圾,就敢上台演出,还敢收费?他们的艺德在哪?哪怕你说的不好,但你准备的很认真,没啥明显失误,虽然感觉表演比较生疏,但大家一看就能看出来,你是精心准备过的,有自己的思考的。等你慢慢的多上台,舞台经验丰富了,风格慢慢的不那么拘谨了,变得比较灵活,比较随心所欲了,观众完全可以接受,我认为高峰高老板就是这样的例子。他早期的相声感觉有点硬,但最近的相声即兴的东西非常多,我很喜欢这种非常放松的表演风格,他虽然现挂,但是一个段子该有的东西都有,他表演的老段子就是教科书级别的。</p><p>但济南相声大会的段子,一看就是没有打磨过的,台下没有好好准备,台上能说到哪段就算哪段。真拿观众不当人呗,真当观众不懂呗,你表演的东西是错的,演的再卖力又有啥用???好东西让你做成了一锅坏水,还不如你不去碰,交给专业人士去做。</p>]]></content>
<summary type="html"><p>今晚心血来潮,去济南相声大会听了会相声。只能说,票价一分钱我都嫌高。</p></summary>
<category term="相声" scheme="https://walu.space/categories/%E7%9B%B8%E5%A3%B0/"/>
<category term="相声" scheme="https://walu.space/tags/%E7%9B%B8%E5%A3%B0/"/>
<category term="娱乐" scheme="https://walu.space/tags/%E5%A8%B1%E4%B9%90/"/>
</entry>
<entry>
<title>音乐没有标准答案</title>
<link href="https://walu.space/2023/09/03/%E9%9F%B3%E4%B9%90%E6%B2%A1%E6%9C%89%E6%A0%87%E5%87%86%E7%AD%94%E6%A1%88/"/>
<id>https://walu.space/2023/09/03/%E9%9F%B3%E4%B9%90%E6%B2%A1%E6%9C%89%E6%A0%87%E5%87%86%E7%AD%94%E6%A1%88/</id>
<published>2023-09-03T03:29:34.000Z</published>
<updated>2023-09-03T07:41:27.245Z</updated>
<content type="html"><![CDATA[<p>音乐的主旨没有标准答案 <span id="more"></span></p><p>周五晚上第一次线下听了古典音乐。<br>本周五洪家楼教堂举办了音乐会,本着丰富自己人生的原则,以及受京吹的影响,报名参加了这次音乐会。之前稍微听过古典音乐,但是感觉听不懂,就没有一直听下去。为了提升本次听音乐的效果,提前听了一下几首曲子。此外,还去知乎搜了一下如何听懂古典音乐,这次搜索结果改变了我的想法,我没有必要一定要弄清楚音乐传递了啥思想,只要音乐好听就行了,作者创作音乐时,可能只是因为好玩,并没有传递啥特殊的想法。平时听的流行音乐,哪怕有歌词存在,我们可能还是无法搞清楚作者到底要传达什么思想,顶多可以分辨是悲伤还是喜悦</p><p>类比语文阅读理解,考察作者使用了什么手法以及文章结构,我完全可以接受,但考察文章表达了什么思想这种作者都无法回答的问题并设置标准答案,我认为是浪费时间,作者可能只是随便写着玩的,他也不知道故事为什么会这么发展,这个故事有什么教化意义。我想这也是我喜欢村上春树的原因,故事自然而然的发生,不用考虑其中的逻辑,只是讲述一个脑中上演的故事,一种自由的感觉。</p><p>PS: 音乐还是要去现场听啊,可以更加精神集中的欣赏音乐。</p>]]></content>
<summary type="html"><p>音乐的主旨没有标准答案</p></summary>
<category term="音乐" scheme="https://walu.space/categories/%E9%9F%B3%E4%B9%90/"/>
<category term="娱乐" scheme="https://walu.space/tags/%E5%A8%B1%E4%B9%90/"/>
<category term="音乐" scheme="https://walu.space/tags/%E9%9F%B3%E4%B9%90/"/>
</entry>
<entry>
<title>点描の唄</title>
<link href="https://walu.space/2023/09/01/%E7%82%B9%E6%8F%8F%E3%81%AE%E5%94%84/"/>
<id>https://walu.space/2023/09/01/%E7%82%B9%E6%8F%8F%E3%81%AE%E5%94%84/</id>
<published>2023-09-01T14:42:26.000Z</published>
<updated>2023-09-03T07:15:20.040Z</updated>
<content type="html"><![CDATA[<p><<点描の唄>>真好听</p><span id="more"></span><p>昨天晚上(8/31)看<a href="https://www.youtube.com/@Hizuki_Yui_">Yui</a>歌枠直播,第一次听到了<a href="https://www.youtube.com/watch?v=S2Va0MCUNVQ&t=4385s">点描の唄</a>,觉得很好听。我非常喜欢她力量感很强的唱法,可能是直播的原因,她有时会气息不足,听不到她以最好的状态唱这首歌,有点遗憾,所以听了<a href="https://open.spotify.com/track/1sIIlVrnPhrvmTrHtzM7tV">原唱</a>,以及几个翻唱。</p><p>这两个是我比较喜欢的翻唱: <a href="https://www.youtube.com/watch?v=RNCEU6O8sx8">レヴィ・エリファ/朝日南アカネ</a>、<a href="https://www.youtube.com/watch?v=AUP3OI9Yhmc">湊あくあ/猫又おかゆ</a><br>相比于原唱的一男一女,我更喜欢两个女生的翻唱,感觉原唱的男声有点虚(⊙x⊙;)。<br>期待<a href="https://www.youtube.com/@amatsuki-official">天月</a><a href="https://www.youtube.com/@96nekoch">96猫</a>一起翻唱这首歌</p>]]></content>
<summary type="html"><p>&lt;&lt;点描の唄&gt;&gt;真好听</p></summary>
<category term="娱乐" scheme="https://walu.space/categories/%E5%A8%B1%E4%B9%90/"/>
<category term="娱乐" scheme="https://walu.space/tags/%E5%A8%B1%E4%B9%90/"/>
<category term="音乐" scheme="https://walu.space/tags/%E9%9F%B3%E4%B9%90/"/>
</entry>
<entry>
<title>WSL2时间错误</title>
<link href="https://walu.space/2023/07/31/WSL2%E6%97%B6%E9%97%B4%E9%94%99%E8%AF%AF/"/>
<id>https://walu.space/2023/07/31/WSL2%E6%97%B6%E9%97%B4%E9%94%99%E8%AF%AF/</id>
<published>2023-07-31T07:43:37.000Z</published>
<updated>2023-07-31T07:44:52.337Z</updated>
<content type="html"><![CDATA[<span id="more"></span><p><a href="https://github.com/microsoft/WSL/issues/5324">https://github.com/microsoft/WSL/issues/5324</a></p>]]></content>
<summary type="html"><span id="more"></span>
<p><a href="https://github.com/microsoft/WSL/issues/5324">https://github.com/microsoft/WSL/issues/5324</a></p>
</summary>
</entry>
<entry>
<title>高峰相声记录</title>
<link href="https://walu.space/2023/07/30/%E9%AB%98%E5%B3%B0%E7%9B%B8%E5%A3%B0%E8%AE%B0%E5%BD%95/"/>
<id>https://walu.space/2023/07/30/%E9%AB%98%E5%B3%B0%E7%9B%B8%E5%A3%B0%E8%AE%B0%E5%BD%95/</id>
<published>2023-07-30T13:07:01.000Z</published>
<updated>2023-07-31T01:20:20.331Z</updated>
<content type="html"><![CDATA[<p>对高峰老师流传在网上的相声视频做个归类整合。</p><span id="more"></span><p>高峰老师几乎每周都会在小园子说相声, 说过非常多的老段子,并且每段都说过好多遍。<br>同一个老段子,过段时间再说,他可能会改动某些包袱,让相声紧贴当下。<br>德云社无论是小园子还是大剧场,都允许观众录像,因此我得以通过网络听到高老师的相声。<br>但如前面所言,高老师说过的相声太多了,搜索他几年前说过的某段相声有点费劲,不如自己把他说过的每段<br>相声都记录下来,日后找的时候也更方便。</p><p>PS: 一项浩大的工程</p><h3 id="十八愁绕口令"><a class="markdownIt-Anchor" href="#十八愁绕口令"></a> 十八愁绕口令</h3><ul><li><a href="https://www.youtube.com/watch?v=OylyuR0xGiE&t=13s">十多年前高峰栾云平专场</a></li><li><a href="https://www.youtube.com/watch?v=piZsfGOZH_8&t=1616s">20230507 高峰 栾云平《十八愁绕口令》</a></li></ul><h3 id="玲珑塔"><a class="markdownIt-Anchor" href="#玲珑塔"></a> 玲珑塔</h3><h3 id="报菜名"><a class="markdownIt-Anchor" href="#报菜名"></a> 报菜名</h3><h3 id="数来宝"><a class="markdownIt-Anchor" href="#数来宝"></a> 数来宝</h3><h3 id="进街数来宝"><a class="markdownIt-Anchor" href="#进街数来宝"></a> 进街数来宝</h3><h3 id="同仁堂"><a class="markdownIt-Anchor" href="#同仁堂"></a> 同仁堂</h3><h3 id="羊上树"><a class="markdownIt-Anchor" href="#羊上树"></a> 羊上树</h3><h3 id="树没叶"><a class="markdownIt-Anchor" href="#树没叶"></a> 树没叶</h3><h3 id="六口人"><a class="markdownIt-Anchor" href="#六口人"></a> 六口人</h3><h3 id="反七口"><a class="markdownIt-Anchor" href="#反七口"></a> 反七口</h3><h3 id="栓娃娃"><a class="markdownIt-Anchor" href="#栓娃娃"></a> 栓娃娃</h3><h3 id="金龟铁甲"><a class="markdownIt-Anchor" href="#金龟铁甲"></a> 金龟铁甲</h3><h3 id="夸住宅"><a class="markdownIt-Anchor" href="#夸住宅"></a> 夸住宅</h3><h3 id="红事会"><a class="markdownIt-Anchor" href="#红事会"></a> 红事会</h3><h3 id="白事会"><a class="markdownIt-Anchor" href="#白事会"></a> 白事会</h3><h3 id="大上寿"><a class="markdownIt-Anchor" href="#大上寿"></a> 大上寿</h3><h3 id="福寿全"><a class="markdownIt-Anchor" href="#福寿全"></a> 福寿全</h3><h3 id="下象棋"><a class="markdownIt-Anchor" href="#下象棋"></a> 下象棋</h3><h3 id="造厨"><a class="markdownIt-Anchor" href="#造厨"></a> 造厨</h3><h3 id="朱夫子"><a class="markdownIt-Anchor" href="#朱夫子"></a> 朱夫子</h3><h3 id="三字经"><a class="markdownIt-Anchor" href="#三字经"></a> 三字经</h3><h3 id="讲四书"><a class="markdownIt-Anchor" href="#讲四书"></a> 讲四书</h3><h3 id="揭瓦"><a class="markdownIt-Anchor" href="#揭瓦"></a> 揭瓦</h3><h3 id="自食其果"><a class="markdownIt-Anchor" href="#自食其果"></a> 自食其果</h3><h3 id="大审案"><a class="markdownIt-Anchor" href="#大审案"></a> 大审案</h3><h3 id="大保镖"><a class="markdownIt-Anchor" href="#大保镖"></a> 大保镖</h3><h3 id="文章会"><a class="markdownIt-Anchor" href="#文章会"></a> 文章会</h3><h3 id="学舞蹈"><a class="markdownIt-Anchor" href="#学舞蹈"></a> 学舞蹈</h3><h3 id="打灯谜"><a class="markdownIt-Anchor" href="#打灯谜"></a> 打灯谜</h3><h3 id="对春联"><a class="markdownIt-Anchor" href="#对春联"></a> 对春联</h3><h3 id="写对子"><a class="markdownIt-Anchor" href="#写对子"></a> 写对子</h3><h3 id="自食其果-2"><a class="markdownIt-Anchor" href="#自食其果-2"></a> 自食其果</h3><h3 id="托妻献子"><a class="markdownIt-Anchor" href="#托妻献子"></a> 托妻献子</h3><h3 id="买卖论"><a class="markdownIt-Anchor" href="#买卖论"></a> 买卖论</h3><h3 id="论梦"><a class="markdownIt-Anchor" href="#论梦"></a> 论梦</h3><h3 id="打砂锅"><a class="markdownIt-Anchor" href="#打砂锅"></a> 打砂锅</h3><h3 id="八大吉祥"><a class="markdownIt-Anchor" href="#八大吉祥"></a> 八大吉祥</h3><h3 id="五行诗"><a class="markdownIt-Anchor" href="#五行诗"></a> 五行诗</h3><h3 id="八扇屏"><a class="markdownIt-Anchor" href="#八扇屏"></a> 八扇屏</h3><h3 id="大登殿"><a class="markdownIt-Anchor" href="#大登殿"></a> 大登殿</h3><h3 id="黄鹤楼"><a class="markdownIt-Anchor" href="#黄鹤楼"></a> 黄鹤楼</h3><h3 id="洪洋洞"><a class="markdownIt-Anchor" href="#洪洋洞"></a> 洪洋洞</h3><h3 id="文昭关"><a class="markdownIt-Anchor" href="#文昭关"></a> 文昭关</h3><h3 id="捉放曹"><a class="markdownIt-Anchor" href="#捉放曹"></a> 捉放曹</h3><h3 id="批捉放"><a class="markdownIt-Anchor" href="#批捉放"></a> 批捉放</h3><h3 id="空城计"><a class="markdownIt-Anchor" href="#空城计"></a> 空城计</h3><h3 id="舞台逸事"><a class="markdownIt-Anchor" href="#舞台逸事"></a> 舞台逸事</h3><h3 id="学方言"><a class="markdownIt-Anchor" href="#学方言"></a> 学方言</h3><h3 id="学四省"><a class="markdownIt-Anchor" href="#学四省"></a> 学四省</h3><h3 id="学外语"><a class="markdownIt-Anchor" href="#学外语"></a> 学外语</h3><h3 id="学方言-2"><a class="markdownIt-Anchor" href="#学方言-2"></a> 学方言</h3><h3 id="学电台"><a class="markdownIt-Anchor" href="#学电台"></a> 学电台</h3><h3 id="学评戏"><a class="markdownIt-Anchor" href="#学评戏"></a> 学评戏</h3><h3 id="武坠子"><a class="markdownIt-Anchor" href="#武坠子"></a> 武坠子</h3><h3 id="弦子书"><a class="markdownIt-Anchor" href="#弦子书"></a> 弦子书</h3>]]></content>
<summary type="html"><p>对高峰老师流传在网上的相声视频做个归类整合。</p></summary>
<category term="相声" scheme="https://walu.space/tags/%E7%9B%B8%E5%A3%B0/"/>
<category term="娱乐" scheme="https://walu.space/tags/%E5%A8%B1%E4%B9%90/"/>
</entry>
<entry>
<title>胧月</title>
<link href="https://walu.space/2023/07/17/%E8%83%A7%E6%9C%88/"/>
<id>https://walu.space/2023/07/17/%E8%83%A7%E6%9C%88/</id>
<published>2023-07-17T15:23:16.000Z</published>
<updated>2023-07-30T14:26:16.035Z</updated>
<content type="html"><![CDATA[<p><a href="https://www.youtube.com/watch?v=KKU98Bn6B-I"><<君色々移り>></a>、<a href="https://www.youtube.com/watch?v=tASF0Vj_-QE"><<忍びのすゝめ>></a>、<a href="https://www.youtube.com/watch?v=8oBp3OLXQ8Q"><<朧月>></a>,三首歌好像可以串起来(⊙o⊙)</p><span id="more"></span> <p>男女主是青梅竹马,后来男主当了忍者,女主进了青楼(○´・д・)ノ<br>好在《忍びのすゝめ》中提到男主是单恋,和《君色々移り》以及《朧月》的歌词略有冲突,不过《君色々移り》和《朧月》还是可以当成一个完整的故事来看 ̄へ ̄</p>]]></content>
<summary type="html"><p><a href="https://www.youtube.com/watch?v=KKU98Bn6B-I">&lt;&lt;君色々移り&gt;&gt;</a>、<a href="https://www.youtube.com/watch?v=tASF0Vj_-QE">&lt;&lt;忍びのすゝめ&gt;&gt;</a>、<a href="https://www.youtube.com/watch?v=8oBp3OLXQ8Q">&lt;&lt;朧月&gt;&gt;</a>,三首歌好像可以串起来(⊙o⊙)</p></summary>
<category term="MafuMafu" scheme="https://walu.space/tags/MafuMafu/"/>
<category term="胡言乱语" scheme="https://walu.space/tags/%E8%83%A1%E8%A8%80%E4%B9%B1%E8%AF%AD/"/>
</entry>
<entry>
<title>鬼泣五一周目</title>
<link href="https://walu.space/2023/07/08/%E9%AC%BC%E6%B3%A3%E4%BA%94%E4%B8%80%E5%91%A8%E7%9B%AE/"/>
<id>https://walu.space/2023/07/08/%E9%AC%BC%E6%B3%A3%E4%BA%94%E4%B8%80%E5%91%A8%E7%9B%AE/</id>
<published>2023-07-08T08:21:20.000Z</published>
<updated>2023-07-08T08:37:53.192Z</updated>
<content type="html"><![CDATA[<p>鬼泣五一周目达成</p><span id="more"></span><p><img src="/2023/07/08/%E9%AC%BC%E6%B3%A3%E4%BA%94%E4%B8%80%E5%91%A8%E7%9B%AE/DevilMayCry5.png" alt="一周目"></p><p>鬼泣五中的招式众多,可以做出非常华丽的动作,单从连招来看,非常耐玩。但剧情有点短,两三句话就能说清楚,还没看过瘾,主线已经结束了。</p>]]></content>
<summary type="html"><p>鬼泣五一周目达成</p></summary>
<category term="娱乐" scheme="https://walu.space/categories/%E5%A8%B1%E4%B9%90/"/>
<category term="游戏" scheme="https://walu.space/tags/%E6%B8%B8%E6%88%8F/"/>
<category term="娱乐" scheme="https://walu.space/tags/%E5%A8%B1%E4%B9%90/"/>
</entry>
<entry>
<title>二叉搜索树中第K小元素</title>
<link href="https://walu.space/2023/07/04/%E4%BA%8C%E5%8F%89%E6%90%9C%E7%B4%A2%E6%A0%91%E4%B8%AD%E7%AC%ACK%E5%B0%8F%E5%85%83%E7%B4%A0/"/>
<id>https://walu.space/2023/07/04/%E4%BA%8C%E5%8F%89%E6%90%9C%E7%B4%A2%E6%A0%91%E4%B8%AD%E7%AC%ACK%E5%B0%8F%E5%85%83%E7%B4%A0/</id>
<published>2023-07-04T13:29:29.000Z</published>
<updated>2023-07-05T15:00:31.925Z</updated>
<content type="html"><![CDATA[<p><a href="https://leetcode.cn/problems/kth-smallest-element-in-a-bst/description/">使用中序遍历获取二叉搜索树中第K小元素</a></p><span id="more"></span> <p><strong>中序遍历二叉搜索树,得到的序列一定是升序的</strong></p><ol><li>使用栈实现中序遍历<br>这是官方解法,思路比较简单,第K个从栈中出来的元素就是要找的。</li></ol><figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">class</span> <span class="title class_">Solution</span> {</span><br><span class="line"><span class="keyword">public</span>:</span><br><span class="line"> <span class="function"><span class="type">int</span> <span class="title">kthSmallest</span><span class="params">(TreeNode* root, <span class="type">int</span> k)</span> </span>{</span><br><span class="line"> stack<TreeNode *> stack;</span><br><span class="line"> <span class="keyword">while</span> (root != <span class="literal">nullptr</span> || stack.<span class="built_in">size</span>() > <span class="number">0</span>) {</span><br><span class="line"> <span class="keyword">while</span> (root != <span class="literal">nullptr</span>) {</span><br><span class="line"> stack.<span class="built_in">push</span>(root);</span><br><span class="line"> root = root->left;</span><br><span class="line"> }</span><br><span class="line"> root = stack.<span class="built_in">top</span>();</span><br><span class="line"> stack.<span class="built_in">pop</span>();</span><br><span class="line"> --k;</span><br><span class="line"> <span class="keyword">if</span> (k == <span class="number">0</span>) {</span><br><span class="line"> <span class="keyword">break</span>;</span><br><span class="line"> }</span><br><span class="line"> root = root->right;</span><br><span class="line"> }</span><br><span class="line"> <span class="keyword">return</span> root->val;</span><br><span class="line"> }</span><br><span class="line">};</span><br></pre></td></tr></table></figure><ol start="2"><li><p>递归实现<br>代码逻辑我还没有想的很清楚,感觉递归也是可以做的,使用传引用的方式,把最终结果(α)当作参数传入函数。<br>使用return值记录递归次数,如果恰好是我们要找的那一次,则修改α的值,并且return -1,告诉上一层,已经找到这个数了,可以直接return。</p></li><li><p>争取明天把递归实现完成,今晚看TICU去了</p></li><li><p>递归解法(2中的思路)</p></li></ol><figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * Definition for a binary tree node.</span></span><br><span class="line"><span class="comment"> * struct TreeNode {</span></span><br><span class="line"><span class="comment"> * int val;</span></span><br><span class="line"><span class="comment"> * TreeNode *left;</span></span><br><span class="line"><span class="comment"> * TreeNode *right;</span></span><br><span class="line"><span class="comment"> * TreeNode() : val(0), left(nullptr), right(nullptr) {}</span></span><br><span class="line"><span class="comment"> * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}</span></span><br><span class="line"><span class="comment"> * TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {}</span></span><br><span class="line"><span class="comment"> * };</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="keyword">class</span> <span class="title class_">Solution</span> {</span><br><span class="line"><span class="keyword">public</span>:</span><br><span class="line"> <span class="function"><span class="type">int</span> <span class="title">kthSmallest</span><span class="params">(TreeNode* root, <span class="type">int</span> k)</span> </span>{</span><br><span class="line"> <span class="type">int</span> res = <span class="number">0</span>;</span><br><span class="line"> <span class="type">int</span> count = <span class="number">0</span>;</span><br><span class="line"> <span class="built_in">solute</span>(root, k, count, res);</span><br><span class="line"> <span class="keyword">return</span> res;</span><br><span class="line"> }</span><br><span class="line"> <span class="function"><span class="type">void</span> <span class="title">solute</span><span class="params">(TreeNode* root, <span class="type">int</span> k, <span class="type">int</span> &count, <span class="type">int</span> &res)</span></span>{</span><br><span class="line"> </span><br><span class="line"> <span class="keyword">if</span>(count == <span class="number">-1</span>){</span><br><span class="line"> <span class="keyword">return</span> ;</span><br><span class="line"> }</span><br><span class="line"> <span class="keyword">if</span>(root == <span class="literal">NULL</span>){</span><br><span class="line"> <span class="keyword">return</span> ;</span><br><span class="line"> }</span><br><span class="line"></span><br><span class="line"> <span class="built_in">solute</span>(root->left, k, count, res);</span><br><span class="line"> <span class="keyword">if</span>(count == <span class="number">-1</span>){</span><br><span class="line"> <span class="keyword">return</span> ;</span><br><span class="line"> }</span><br><span class="line"> count += <span class="number">1</span>;</span><br><span class="line"> <span class="keyword">if</span>(count == k){</span><br><span class="line"> count = <span class="number">-1</span>;</span><br><span class="line"> res = root->val;</span><br><span class="line"> cout << <span class="string">"res: "</span> << res << endl;</span><br><span class="line"> <span class="keyword">return</span> ;</span><br><span class="line"> }</span><br><span class="line"> <span class="built_in">solute</span>(root->right, k, count, res);</span><br><span class="line"> <span class="keyword">if</span>(count == <span class="number">-1</span>){</span><br><span class="line"> <span class="keyword">return</span> ;</span><br><span class="line"> }</span><br><span class="line"> <span class="keyword">if</span>(count == k){</span><br><span class="line"> count = <span class="number">-1</span>;</span><br><span class="line"> res = root->val;</span><br><span class="line"> <span class="keyword">return</span> ;</span><br><span class="line"> }</span><br><span class="line"></span><br><span class="line"> }</span><br><span class="line">};</span><br></pre></td></tr></table></figure>]]></content>
<summary type="html"><p><a href="https://leetcode.cn/problems/kth-smallest-element-in-a-bst/description/">使用中序遍历获取二叉搜索树中第K小元素</a></p></summary>
<category term="算法" scheme="https://walu.space/categories/%E7%AE%97%E6%B3%95/"/>
<category term="算法" scheme="https://walu.space/tags/%E7%AE%97%E6%B3%95/"/>
<category term="二叉树" scheme="https://walu.space/tags/%E4%BA%8C%E5%8F%89%E6%A0%91/"/>
<category term="刷题" scheme="https://walu.space/tags/%E5%88%B7%E9%A2%98/"/>
</entry>
<entry>
<title>Notion的缺陷</title>
<link href="https://walu.space/2023/06/28/Notion%E7%9A%84%E7%BC%BA%E9%99%B7/"/>
<id>https://walu.space/2023/06/28/Notion%E7%9A%84%E7%BC%BA%E9%99%B7/</id>
<published>2023-06-28T09:05:14.000Z</published>
<updated>2023-06-28T09:36:59.773Z</updated>
<content type="html"><![CDATA[<p>今天下午折腾了好几个小时的Notion ToDo List,发现很多我想要的功能都没有(;´д`)ゞ</p><span id="more"></span><h3 id="1-模板自动填充时间"><a class="markdownIt-Anchor" href="#1-模板自动填充时间"></a> 1. 模板自动填充时间</h3><p>Notion的模板虽然可以设置自动重复,但是没法做到自动填充当前时间。背单词、刷题等任务,是我每天都会做的,所以我会让Notion模板每天都创建相同的任务,但扯淡的是,他不支持自动更新时间,你在模板上写的是哪天,重复创建每日任务的时候,时间写的还是那天,需要自己把时间改成今天</p><h3 id="2-table-view"><a class="markdownIt-Anchor" href="#2-table-view"></a> 2. Table View</h3><p>一个页面不能放两个Table View。全部的任务都放在数据库中,通过创建Table View并且设置Filter可以筛选出自己想要的内容,但Notion不支持一个页面中有多个Table View,所以,要想在一个页面同时看到两种相互冲突的任务,只能再加一个变量并且使用group进行分类</p><h3 id="3-最后编辑时间"><a class="markdownIt-Anchor" href="#3-最后编辑时间"></a> 3. 最后编辑时间</h3><p>Notion不支持获取某一列的最后编辑时间</p><h3 id="4-分组下拉填充"><a class="markdownIt-Anchor" href="#4-分组下拉填充"></a> 4. 分组&下拉填充</h3><p>当使用group进行分组后,下拉填充功能又不好用了🤬</p><h3 id="5-未来优化"><a class="markdownIt-Anchor" href="#5-未来优化"></a> 5. 未来优化</h3><p>希望Notion将来可以内置Python解释器,或者微软直接Copy一个Notion(<a href="https://www.microsoft.com/en-us/microsoft-loop">微软已经在这么做了</a>),让他的DataBase、Formula更加强大</p>]]></content>
<summary type="html"><p>今天下午折腾了好几个小时的Notion ToDo List,发现很多我想要的功能都没有(;´д`)ゞ</p></summary>
<category term="软件" scheme="https://walu.space/categories/%E8%BD%AF%E4%BB%B6/"/>
<category term="软件" scheme="https://walu.space/tags/%E8%BD%AF%E4%BB%B6/"/>
<category term="Notion" scheme="https://walu.space/tags/Notion/"/>
</entry>
<entry>
<title>再也不碰炉石传说了</title>
<link href="https://walu.space/2023/06/24/%E5%86%8D%E4%B9%9F%E4%B8%8D%E7%A2%B0%E7%82%89%E7%9F%B3%E4%BC%A0%E8%AF%B4%E4%BA%86/"/>
<id>https://walu.space/2023/06/24/%E5%86%8D%E4%B9%9F%E4%B8%8D%E7%A2%B0%E7%82%89%E7%9F%B3%E4%BC%A0%E8%AF%B4%E4%BA%86/</id>
<published>2023-06-24T06:14:41.000Z</published>
<updated>2023-06-24T07:00:47.261Z</updated>
<content type="html"><![CDATA[<p>中午玩炉石标准模式破防了,一局都没赢┗|`O′|┛</p><span id="more"></span><p>工作的时候,组了套40血DK<br>靠这套卡组上了白金,但死活打不到钻石<br>今天中午又想玩一下,打了四把,其中两个牧师,一个盗贼,一个法师。</p><h3 id="牧师"><a class="markdownIt-Anchor" href="#牧师"></a> 牧师</h3><ol><li>控制牧<br>偷牌好恶心,直接偷到了我的翻倍和帕奇维克,并且用偷到的帕奇维克又撕了我的希尔瓦娜斯。想着往后再坚持一下,等翻倍到了我还有一战之力,结果翻倍来的时候,我就剩14张牌了,血量也不高了,他直接拍出一个血誓,而我没抽到解牌,自己退了。</li><li>暗牧<br>暗牧前期天胡开局,而我前期没有啥解牌手段,5费用邪爆解了个场面,结果6费他直接复活了上个回合被我解掉的随从。想着下一轮有可能神抽,上了个嘲讽怪苟活一轮,结果被他用法术解掉了,直接被踢死。</li></ol><h3 id="盗贼"><a class="markdownIt-Anchor" href="#盗贼"></a> 盗贼</h3><ol><li>剑鱼贼<br>使用一堆BUFF,剑鱼刀加到了16点攻击力,4耐久,并且一堆单解,没有抗住,被砍死了。</li></ol><h3 id="法师"><a class="markdownIt-Anchor" href="#法师"></a> 法师</h3><ol><li>奥秘法<br>两个法反,两个生反,我的牌又都比较高费,前期血线被压得很低,后面直接两个4费打6的法术把我带走。</li></ol><h3 id="总结"><a class="markdownIt-Anchor" href="#总结"></a> 总结</h3><ol><li>40血DK就是沙包,对阵快攻,前期没啥自保能力,可能解牌还没抽到,就已经被踢死了。<br>打慢速卡组,一局一二十分钟,拼谁的资源多。牧师有女武神,相当于无限法术;法师有巅峰,也相当于无限法术;大哥术可以搞个无限瑞文;奥秘贼奥秘不停,最后再来个苔丝。打上面的慢速,感觉血DK十分乏力,除非7费准时翻倍,并且8非再用蛇发女妖把翻倍拿回来,二次翻倍,否则打慢速也感觉很难打。</li><li>现在非常讨厌炉石。这一局能不能赢,运气占比很大;卡组之间有明显的强弱之分,且存在克制关系(设计师就不能把所有的卡组都设计成55开的局面吗!!!单从数学上来讲,有可能把所有的卡组都设计成55开并且还各具特色吗?)</li><li>这种输赢靠运气影响比较大的游戏,仔细一想,和赌博比较类似。赌博真的有人能够算出来自己赢的概率吗?真的有人能够根据微表情,推测出对方的点数吗?同理,炉石这种游戏,可以从一开始就把自己取胜的概率算出来吗?</li><li>以后想玩游戏,我还是老老实实打开我的steam吧,《鬼泣5》买回来后还没玩过。</li></ol>]]></content>
<summary type="html"><p>中午玩炉石标准模式破防了,一局都没赢┗|`O′|┛</p></summary>
<category term="胡言乱语" scheme="https://walu.space/categories/%E8%83%A1%E8%A8%80%E4%B9%B1%E8%AF%AD/"/>
<category term="游戏" scheme="https://walu.space/tags/%E6%B8%B8%E6%88%8F/"/>
</entry>
<entry>
<title>对称二叉树</title>
<link href="https://walu.space/2023/06/23/%E5%AF%B9%E7%A7%B0%E4%BA%8C%E5%8F%89%E6%A0%91/"/>
<id>https://walu.space/2023/06/23/%E5%AF%B9%E7%A7%B0%E4%BA%8C%E5%8F%89%E6%A0%91/</id>
<published>2023-06-23T15:12:44.000Z</published>
<updated>2023-06-23T15:39:59.992Z</updated>
<content type="html"><![CDATA[<p>使用迭代判断二叉树是否对称</p><span id="more"></span><figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * Definition for a binary tree node.</span></span><br><span class="line"><span class="comment"> * struct TreeNode {</span></span><br><span class="line"><span class="comment"> * int val;</span></span><br><span class="line"><span class="comment"> * TreeNode *left;</span></span><br><span class="line"><span class="comment"> * TreeNode *right;</span></span><br><span class="line"><span class="comment"> * TreeNode() : val(0), left(nullptr), right(nullptr) {}</span></span><br><span class="line"><span class="comment"> * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}</span></span><br><span class="line"><span class="comment"> * TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {}</span></span><br><span class="line"><span class="comment"> * };</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="keyword">class</span> <span class="title class_">Solution</span> {</span><br><span class="line"><span class="keyword">public</span>:</span><br><span class="line"> <span class="function"><span class="type">bool</span> <span class="title">isSymmetric</span><span class="params">(TreeNode* root)</span> </span>{</span><br><span class="line"> <span class="keyword">if</span>(root == <span class="literal">NULL</span>){</span><br><span class="line"> <span class="keyword">return</span> <span class="literal">true</span>;</span><br><span class="line"> }<span class="keyword">else</span>{</span><br><span class="line"> stack<TreeNode*> LeftTree;</span><br><span class="line"> stack<TreeNode*> RightTree;</span><br><span class="line"> TreeNode* left = root->left;</span><br><span class="line"> TreeNode* right = root->right;</span><br><span class="line"> LeftTree.<span class="built_in">push</span>(left);</span><br><span class="line"> RightTree.<span class="built_in">push</span>(right);</span><br><span class="line"> <span class="keyword">while</span>(!LeftTree.<span class="built_in">empty</span>() && !RightTree.<span class="built_in">empty</span>()){</span><br><span class="line"> TreeNode* tmp1 = LeftTree.<span class="built_in">top</span>();</span><br><span class="line"> TreeNode* tmp2 = RightTree.<span class="built_in">top</span>();</span><br><span class="line"> LeftTree.<span class="built_in">pop</span>();</span><br><span class="line"> RightTree.<span class="built_in">pop</span>();</span><br><span class="line"> <span class="keyword">if</span>(tmp1 == <span class="literal">NULL</span> && tmp2 == <span class="literal">NULL</span>){</span><br><span class="line"> <span class="keyword">return</span> <span class="literal">true</span>;</span><br><span class="line"> }</span><br><span class="line"> <span class="keyword">if</span>(tmp1 == <span class="literal">NULL</span> || tmp2 == <span class="literal">NULL</span>){</span><br><span class="line"> <span class="keyword">return</span> <span class="literal">false</span>;</span><br><span class="line"> }</span><br><span class="line"> <span class="keyword">if</span>(tmp1->val == tmp2->val){</span><br><span class="line"> <span class="keyword">if</span>(tmp1->left != <span class="literal">NULL</span> && tmp2->right != <span class="literal">NULL</span>){</span><br><span class="line"> LeftTree.<span class="built_in">push</span>(tmp1->left);</span><br><span class="line"> RightTree.<span class="built_in">push</span>(tmp2->right);</span><br><span class="line"> }<span class="keyword">else</span> <span class="keyword">if</span>(tmp1->left == <span class="literal">NULL</span> && tmp2->right == <span class="literal">NULL</span>){</span><br><span class="line"> ;</span><br><span class="line"> }<span class="keyword">else</span>{</span><br><span class="line"> <span class="keyword">return</span> <span class="literal">false</span>;</span><br><span class="line"> }</span><br><span class="line"> <span class="keyword">if</span>(tmp1->right != <span class="literal">NULL</span> && tmp2->left != <span class="literal">NULL</span>){</span><br><span class="line"> LeftTree.<span class="built_in">push</span>(tmp1->right);</span><br><span class="line"> RightTree.<span class="built_in">push</span>(tmp2->left);</span><br><span class="line"> }<span class="keyword">else</span> <span class="keyword">if</span>(tmp1->right == <span class="literal">NULL</span> && tmp2->left == <span class="literal">NULL</span>){</span><br><span class="line"> ;</span><br><span class="line"> }</span><br><span class="line"> <span class="keyword">else</span>{</span><br><span class="line"> <span class="keyword">return</span> <span class="literal">false</span>;</span><br><span class="line"> }</span><br><span class="line"> }<span class="keyword">else</span>{</span><br><span class="line"> <span class="keyword">return</span> <span class="literal">false</span>;</span><br><span class="line"> }</span><br><span class="line"> }</span><br><span class="line"> }</span><br><span class="line"> <span class="keyword">return</span> <span class="literal">true</span>;</span><br><span class="line"> }</span><br><span class="line">};</span><br></pre></td></tr></table></figure>]]></content>
<summary type="html"><p>使用迭代判断二叉树是否对称</p></summary>
<category term="算法" scheme="https://walu.space/categories/%E7%AE%97%E6%B3%95/"/>
<category term="算法" scheme="https://walu.space/tags/%E7%AE%97%E6%B3%95/"/>
<category term="二叉树" scheme="https://walu.space/tags/%E4%BA%8C%E5%8F%89%E6%A0%91/"/>
</entry>
<entry>
<title>TraverseBinaryTree</title>
<link href="https://walu.space/2023/06/21/TraverseBinaryTree/"/>
<id>https://walu.space/2023/06/21/TraverseBinaryTree/</id>
<published>2023-06-21T14:54:46.000Z</published>
<updated>2023-06-24T07:06:01.634Z</updated>
<content type="html"><![CDATA[<p>使用C++实现二叉树的前中后序遍历&层序遍历</p><span id="more"></span><blockquote><p>对于二叉树的前中后序遍历,在实际开发中,真的会有人用栈来实现吗?</p></blockquote><h3 id="前序遍历"><a class="markdownIt-Anchor" href="#前序遍历"></a> 前序遍历</h3><ol><li>使用递归实现</li></ol><figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * Definition for a binary tree node.</span></span><br><span class="line"><span class="comment"> * struct TreeNode {</span></span><br><span class="line"><span class="comment"> * int val;</span></span><br><span class="line"><span class="comment"> * TreeNode *left;</span></span><br><span class="line"><span class="comment"> * TreeNode *right;</span></span><br><span class="line"><span class="comment"> * TreeNode() : val(0), left(nullptr), right(nullptr) {}</span></span><br><span class="line"><span class="comment"> * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}</span></span><br><span class="line"><span class="comment"> * TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {}</span></span><br><span class="line"><span class="comment"> * };</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="keyword">class</span> <span class="title class_">Solution</span> {</span><br><span class="line"><span class="keyword">public</span>:</span><br><span class="line"> <span class="function">vector<<span class="type">int</span>> <span class="title">preorderTraversal</span><span class="params">(TreeNode* root)</span> </span>{</span><br><span class="line"> vector<<span class="type">int</span>> res;</span><br><span class="line"> <span class="built_in">preOrder</span>(root, res);</span><br><span class="line"> <span class="keyword">return</span> res;</span><br><span class="line"> }</span><br><span class="line"></span><br><span class="line"> <span class="function"><span class="type">void</span> <span class="title">preOrder</span><span class="params">(TreeNode* root, vector<<span class="type">int</span>> &res)</span></span>{</span><br><span class="line"> <span class="keyword">if</span>(root == <span class="literal">NULL</span>){</span><br><span class="line"> <span class="keyword">return</span>;</span><br><span class="line"> }</span><br><span class="line"> res.<span class="built_in">push_back</span>(root->val);</span><br><span class="line"> <span class="built_in">preOrder</span>(root->left, res);</span><br><span class="line"> <span class="built_in">preOrder</span>(root->right, res);</span><br><span class="line"> }</span><br><span class="line">};</span><br></pre></td></tr></table></figure><ol start="2"><li>使用栈实现</li></ol><figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * Definition for a binary tree node.</span></span><br><span class="line"><span class="comment"> * struct TreeNode {</span></span><br><span class="line"><span class="comment"> * int val;</span></span><br><span class="line"><span class="comment"> * TreeNode *left;</span></span><br><span class="line"><span class="comment"> * TreeNode *right;</span></span><br><span class="line"><span class="comment"> * TreeNode() : val(0), left(nullptr), right(nullptr) {}</span></span><br><span class="line"><span class="comment"> * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}</span></span><br><span class="line"><span class="comment"> * TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {}</span></span><br><span class="line"><span class="comment"> * };</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="keyword">class</span> <span class="title class_">Solution</span> {</span><br><span class="line"><span class="keyword">public</span>:</span><br><span class="line"> <span class="function">vector<<span class="type">int</span>> <span class="title">preorderTraversal</span><span class="params">(TreeNode* root)</span> </span>{</span><br><span class="line"> stack<TreeNode*> stack;</span><br><span class="line"> vector<<span class="type">int</span>> res;</span><br><span class="line"> <span class="keyword">if</span>(root == <span class="literal">NULL</span>){</span><br><span class="line"> <span class="keyword">return</span> res;</span><br><span class="line"> }</span><br><span class="line"> stack.<span class="built_in">push</span>(root);</span><br><span class="line"> <span class="keyword">while</span>(!stack.<span class="built_in">empty</span>()){</span><br><span class="line"> TreeNode* tmp = stack.<span class="built_in">top</span>();</span><br><span class="line"> stack.<span class="built_in">pop</span>();</span><br><span class="line"> res.<span class="built_in">push_back</span>(tmp->val);</span><br><span class="line"> <span class="keyword">if</span>(tmp->right != <span class="literal">NULL</span>){</span><br><span class="line"> stack.<span class="built_in">push</span>(tmp->right);</span><br><span class="line"> }</span><br><span class="line"> <span class="keyword">if</span>(tmp->left != <span class="literal">NULL</span>){</span><br><span class="line"> stack.<span class="built_in">push</span>(tmp->left);</span><br><span class="line"> }</span><br><span class="line"> }</span><br><span class="line"> <span class="keyword">return</span> res;</span><br><span class="line"> }</span><br><span class="line">};</span><br></pre></td></tr></table></figure><h3 id="中序遍历"><a class="markdownIt-Anchor" href="#中序遍历"></a> 中序遍历</h3><ol><li>使用递归实现</li></ol><figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * Definition for a binary tree node.</span></span><br><span class="line"><span class="comment"> * struct TreeNode {</span></span><br><span class="line"><span class="comment"> * int val;</span></span><br><span class="line"><span class="comment"> * TreeNode *left;</span></span><br><span class="line"><span class="comment"> * TreeNode *right;</span></span><br><span class="line"><span class="comment"> * TreeNode() : val(0), left(nullptr), right(nullptr) {}</span></span><br><span class="line"><span class="comment"> * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}</span></span><br><span class="line"><span class="comment"> * TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {}</span></span><br><span class="line"><span class="comment"> * };</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="keyword">class</span> <span class="title class_">Solution</span> {</span><br><span class="line"><span class="keyword">public</span>:</span><br><span class="line"> <span class="function">vector<<span class="type">int</span>> <span class="title">inorderTraversal</span><span class="params">(TreeNode* root)</span> </span>{</span><br><span class="line"> vector<<span class="type">int</span>> res;</span><br><span class="line"> <span class="built_in">inOrder</span>(root, res);</span><br><span class="line"> <span class="keyword">return</span> res;</span><br><span class="line"> }</span><br><span class="line"></span><br><span class="line"> <span class="function"><span class="type">void</span> <span class="title">inOrder</span><span class="params">(TreeNode* root, vector<<span class="type">int</span>> &res)</span></span>{</span><br><span class="line"> <span class="keyword">if</span>(root == <span class="literal">NULL</span>){</span><br><span class="line"> <span class="keyword">return</span>;</span><br><span class="line"> }</span><br><span class="line"> <span class="built_in">inOrder</span>(root->left, res);</span><br><span class="line"> res.<span class="built_in">push_back</span>(root->val);</span><br><span class="line"> <span class="built_in">inOrder</span>(root->right, res);</span><br><span class="line"> }</span><br><span class="line">};</span><br></pre></td></tr></table></figure><ol start="2"><li>使用栈实现</li></ol><figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * Definition for a binary tree node.</span></span><br><span class="line"><span class="comment"> * struct TreeNode {</span></span><br><span class="line"><span class="comment"> * int val;</span></span><br><span class="line"><span class="comment"> * TreeNode *left;</span></span><br><span class="line"><span class="comment"> * TreeNode *right;</span></span><br><span class="line"><span class="comment"> * TreeNode() : val(0), left(nullptr), right(nullptr) {}</span></span><br><span class="line"><span class="comment"> * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}</span></span><br><span class="line"><span class="comment"> * TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {}</span></span><br><span class="line"><span class="comment"> * };</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="keyword">class</span> <span class="title class_">Solution</span> {</span><br><span class="line"><span class="keyword">public</span>:</span><br><span class="line"> <span class="function">vector<<span class="type">int</span>> <span class="title">inorderTraversal</span><span class="params">(TreeNode* root)</span> </span>{</span><br><span class="line"> stack<TreeNode*> stack;</span><br><span class="line"> vector<<span class="type">int</span>> res;</span><br><span class="line"> <span class="keyword">if</span>(root == <span class="literal">NULL</span>){</span><br><span class="line"> <span class="keyword">return</span> res;</span><br><span class="line"> }</span><br><span class="line"> <span class="keyword">while</span>(root != <span class="literal">NULL</span> || !stack.<span class="built_in">empty</span>()){</span><br><span class="line"> <span class="keyword">if</span>(root != <span class="literal">NULL</span>){</span><br><span class="line"> <span class="keyword">while</span>(root != <span class="literal">NULL</span>){</span><br><span class="line"> stack.<span class="built_in">push</span>(root);</span><br><span class="line"> root = root->left;</span><br><span class="line"> }</span><br><span class="line"> }<span class="keyword">else</span>{</span><br><span class="line"> root = stack.<span class="built_in">top</span>();</span><br><span class="line"> stack.<span class="built_in">pop</span>();</span><br><span class="line"> res.<span class="built_in">push_back</span>(root->val);</span><br><span class="line"> root = root->right;</span><br><span class="line"> }</span><br><span class="line"> }</span><br><span class="line"> <span class="keyword">return</span> res;</span><br><span class="line"> }</span><br><span class="line">};</span><br></pre></td></tr></table></figure><h3 id="后续遍历"><a class="markdownIt-Anchor" href="#后续遍历"></a> 后续遍历</h3><ol><li>使用递归实现</li></ol><figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * Definition for a binary tree node.</span></span><br><span class="line"><span class="comment"> * struct TreeNode {</span></span><br><span class="line"><span class="comment"> * int val;</span></span><br><span class="line"><span class="comment"> * TreeNode *left;</span></span><br><span class="line"><span class="comment"> * TreeNode *right;</span></span><br><span class="line"><span class="comment"> * TreeNode() : val(0), left(nullptr), right(nullptr) {}</span></span><br><span class="line"><span class="comment"> * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}</span></span><br><span class="line"><span class="comment"> * TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {}</span></span><br><span class="line"><span class="comment"> * };</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="keyword">class</span> <span class="title class_">Solution</span> {</span><br><span class="line"><span class="keyword">public</span>:</span><br><span class="line"> <span class="function">vector<<span class="type">int</span>> <span class="title">postorderTraversal</span><span class="params">(TreeNode* root)</span> </span>{</span><br><span class="line"> vector<<span class="type">int</span>> res;</span><br><span class="line"> <span class="built_in">postOrder</span>(root, res);</span><br><span class="line"> <span class="keyword">return</span> res;</span><br><span class="line"> }</span><br><span class="line"> <span class="function"><span class="type">void</span> <span class="title">postOrder</span><span class="params">(TreeNode* root, vector<<span class="type">int</span>> &res)</span></span>{</span><br><span class="line"> <span class="keyword">if</span>(root == <span class="literal">NULL</span>){</span><br><span class="line"> <span class="keyword">return</span>;</span><br><span class="line"> }</span><br><span class="line"> <span class="built_in">postOrder</span>(root->left, res);</span><br><span class="line"> <span class="built_in">postOrder</span>(root->right, res);</span><br><span class="line"> res.<span class="built_in">push_back</span>(root->val);</span><br><span class="line"> }</span><br><span class="line">};</span><br></pre></td></tr></table></figure><ol start="2"><li>使用栈实现<br>我傻傻的想要只用一个栈来实现后序遍历,看过题解之后,大家都是用两个栈来实现的。不过在思考过程中,想出了“中右左”遍历,再对遍历的结果前后翻转的解法。</li></ol><figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * Definition for a binary tree node.</span></span><br><span class="line"><span class="comment"> * struct TreeNode {</span></span><br><span class="line"><span class="comment"> * int val;</span></span><br><span class="line"><span class="comment"> * TreeNode *left;</span></span><br><span class="line"><span class="comment"> * TreeNode *right;</span></span><br><span class="line"><span class="comment"> * TreeNode() : val(0), left(nullptr), right(nullptr) {}</span></span><br><span class="line"><span class="comment"> * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}</span></span><br><span class="line"><span class="comment"> * TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {}</span></span><br><span class="line"><span class="comment"> * };</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="keyword">class</span> <span class="title class_">Solution</span> {</span><br><span class="line"><span class="keyword">public</span>:</span><br><span class="line"> <span class="function">vector<<span class="type">int</span>> <span class="title">postorderTraversal</span><span class="params">(TreeNode* root)</span> </span>{</span><br><span class="line"> stack<TreeNode*> stack;</span><br><span class="line"> vector<<span class="type">int</span>> res;</span><br><span class="line"> <span class="keyword">if</span>(root == <span class="literal">NULL</span>){</span><br><span class="line"> <span class="keyword">return</span> res;</span><br><span class="line"> }</span><br><span class="line"> stack.<span class="built_in">push</span>(root);</span><br><span class="line"> <span class="keyword">while</span>(!stack.<span class="built_in">empty</span>()){</span><br><span class="line"> TreeNode* tmp = stack.<span class="built_in">top</span>();</span><br><span class="line"> stack.<span class="built_in">pop</span>();</span><br><span class="line"> res.<span class="built_in">push_back</span>(tmp->val);</span><br><span class="line"> <span class="keyword">if</span>(tmp->left != <span class="literal">NULL</span>){</span><br><span class="line"> stack.<span class="built_in">push</span>(tmp->left);</span><br><span class="line"> }</span><br><span class="line"> <span class="keyword">if</span>(tmp->right != <span class="literal">NULL</span>){</span><br><span class="line"> stack.<span class="built_in">push</span>(tmp->right);</span><br><span class="line"> }</span><br><span class="line"> }</span><br><span class="line"> <span class="built_in">reverse</span>(res.<span class="built_in">begin</span>(), res.<span class="built_in">end</span>());</span><br><span class="line"> <span class="keyword">return</span> res;</span><br><span class="line"> }</span><br><span class="line">};</span><br></pre></td></tr></table></figure><h3 id="层序遍历"><a class="markdownIt-Anchor" href="#层序遍历"></a> 层序遍历</h3><blockquote><p>每一层单独使用一个vector存储</p></blockquote><figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * Definition for a binary tree node.</span></span><br><span class="line"><span class="comment"> * struct TreeNode {</span></span><br><span class="line"><span class="comment"> * int val;</span></span><br><span class="line"><span class="comment"> * TreeNode *left;</span></span><br><span class="line"><span class="comment"> * TreeNode *right;</span></span><br><span class="line"><span class="comment"> * TreeNode() : val(0), left(nullptr), right(nullptr) {}</span></span><br><span class="line"><span class="comment"> * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}</span></span><br><span class="line"><span class="comment"> * TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {}</span></span><br><span class="line"><span class="comment"> * };</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="keyword">class</span> <span class="title class_">Solution</span> {</span><br><span class="line"><span class="keyword">public</span>:</span><br><span class="line"> vector<vector<<span class="type">int</span>>> <span class="built_in">levelOrder</span>(TreeNode* root) {</span><br><span class="line"> </span><br><span class="line"> vector<vector<<span class="type">int</span>>> res;</span><br><span class="line"> <span class="keyword">if</span>(root == <span class="literal">NULL</span>){</span><br><span class="line"> <span class="keyword">return</span> res;</span><br><span class="line"> }</span><br><span class="line"> queue<TreeNode*> gquiz;</span><br><span class="line"> gquiz.<span class="built_in">push</span>(root);</span><br><span class="line"> <span class="type">int</span> length;</span><br><span class="line"></span><br><span class="line"> <span class="keyword">while</span>(!gquiz.<span class="built_in">empty</span>()){</span><br><span class="line"> res.<span class="built_in">push_back</span>(<span class="built_in">vector</span><<span class="type">int</span>>());</span><br><span class="line"> length = gquiz.<span class="built_in">size</span>();</span><br><span class="line"> <span class="keyword">for</span>(<span class="type">int</span> i=<span class="number">0</span>; i<length; i++){</span><br><span class="line"> TreeNode* tmp = gquiz.<span class="built_in">front</span>();</span><br><span class="line"> res.<span class="built_in">back</span>().<span class="built_in">push_back</span>(tmp->val);</span><br><span class="line"> gquiz.<span class="built_in">pop</span>();</span><br><span class="line"> <span class="keyword">if</span>(tmp->left != <span class="literal">NULL</span>){</span><br><span class="line"> gquiz.<span class="built_in">push</span>(tmp->left);</span><br><span class="line"> }</span><br><span class="line"> <span class="keyword">if</span>(tmp->right != <span class="literal">NULL</span>){</span><br><span class="line"> gquiz.<span class="built_in">push</span>(tmp->right);</span><br><span class="line"> }</span><br><span class="line"> }</span><br><span class="line"> }</span><br><span class="line"> <span class="keyword">return</span> res;</span><br><span class="line"> }</span><br><span class="line">};</span><br></pre></td></tr></table></figure>]]></content>
<summary type="html"><p>使用C++实现二叉树的前中后序遍历&amp;层序遍历</p></summary>
<category term="算法" scheme="https://walu.space/categories/%E7%AE%97%E6%B3%95/"/>
<category term="算法" scheme="https://walu.space/tags/%E7%AE%97%E6%B3%95/"/>
<category term="二叉树" scheme="https://walu.space/tags/%E4%BA%8C%E5%8F%89%E6%A0%91/"/>
</entry>
<entry>
<title>KMP</title>
<link href="https://walu.space/2023/06/18/KMP/"/>
<id>https://walu.space/2023/06/18/KMP/</id>
<published>2023-06-18T12:58:57.000Z</published>
<updated>2023-06-18T15:15:43.122Z</updated>
<content type="html"><![CDATA[<p>重学<a href="https://www.youtube.com/watch?v=3IFxpozBs2I&t=826s">KMP算法</a>,列出学习过程中我比较困惑的地方,给出前缀表的python实现</p><span id="more"></span><h3 id="较难理解的部分"><a class="markdownIt-Anchor" href="#较难理解的部分"></a> 较难理解的部分</h3><blockquote><p>使用python实现前缀表的计算,加深对2的理解</p></blockquote><ol><li>为什么要计算最长公共前后缀</li><li>增加字符,最长公共前后缀无法变长时怎么处理</li></ol><h3 id="前缀表代码实现"><a class="markdownIt-Anchor" href="#前缀表代码实现"></a> 前缀表代码实现</h3><blockquote><p>感觉实现方式有点像双指针+递归</p></blockquote><ol><li>python</li></ol><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">def</span> <span class="title function_">prefix_table</span>(<span class="params">pattern</span>):</span><br><span class="line"> <span class="comment"># the lingest common prefix and suffix</span></span><br><span class="line"> length = <span class="number">0</span></span><br><span class="line"> <span class="comment"># prefix table & init</span></span><br><span class="line"> prefix = [<span class="number">0</span>]</span><br><span class="line"> <span class="comment">#index of the prefix table </span></span><br><span class="line"> i = <span class="number">1</span></span><br><span class="line"> <span class="keyword">while</span>(i<<span class="built_in">len</span>(pattern)):</span><br><span class="line"> <span class="built_in">print</span>(<span class="string">"length {:d}, index: {:d}"</span>.<span class="built_in">format</span>(length, i))</span><br><span class="line"> <span class="keyword">if</span>(pattern[i] == pattern[length]):</span><br><span class="line"> length += <span class="number">1</span></span><br><span class="line"> prefix.append(length)</span><br><span class="line"> i += <span class="number">1</span></span><br><span class="line"> <span class="keyword">else</span>:</span><br><span class="line"> <span class="comment"># 如果不能和上一个最长公共前后缀组成更长的公共前后缀,使最长公共前后缀减一,</span></span><br><span class="line"> <span class="comment"># 考虑能不能和减一之后的公共前后缀组成一个更长的公共前后缀</span></span><br><span class="line"> <span class="comment"># 总结:既然和A组合之后没法生成更长的公共前后缀,那我就和试着和A的子串组合。</span></span><br><span class="line"> <span class="keyword">if</span>(length<=<span class="number">0</span>):</span><br><span class="line"> prefix.append(<span class="number">0</span>)</span><br><span class="line"> i += <span class="number">1</span></span><br><span class="line"> <span class="keyword">else</span>:</span><br><span class="line"> <span class="comment"># 关键一步,找到最长公共前后缀的最长公共前后缀</span></span><br><span class="line"> length = prefix[length-<span class="number">1</span>]</span><br><span class="line"> <span class="keyword">return</span> prefix</span><br><span class="line"></span><br><span class="line"><span class="keyword">if</span> __name__ == <span class="string">'__main__'</span>:</span><br><span class="line"> pattern = <span class="string">"ABABCABAA"</span></span><br><span class="line"> prefix = prefix_table(pattern)</span><br><span class="line"> <span class="built_in">print</span>(prefix)</span><br></pre></td></tr></table></figure><ol start="2"><li>C语言(抄的黄浩杰大佬的)</li></ol><figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string"><stdio.h></span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string"><stdlib.h></span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string"><string.h></span></span></span><br><span class="line"></span><br><span class="line"><span class="type">void</span> <span class="title function_">prefix_table</span><span class="params">(<span class="type">char</span> pattern[], <span class="type">int</span> prefix[], <span class="type">int</span> n)</span> {</span><br><span class="line"> prefix[<span class="number">0</span>] = <span class="number">0</span>;</span><br><span class="line"> <span class="type">int</span> len = <span class="number">0</span>;</span><br><span class="line"> <span class="type">int</span> i = <span class="number">1</span>;</span><br><span class="line"> <span class="keyword">while</span> (i < n) {</span><br><span class="line"> <span class="keyword">if</span> (pattern[i] == pattern[len]) {</span><br><span class="line"> len++;</span><br><span class="line"> prefix[i] = len;</span><br><span class="line"> i++;</span><br><span class="line"> } <span class="keyword">else</span> {</span><br><span class="line"> <span class="keyword">if</span> (len > <span class="number">0</span>) {</span><br><span class="line"> len = prefix[len - <span class="number">1</span>];</span><br><span class="line"> } <span class="keyword">else</span> {</span><br><span class="line"> prefix[i] = len;</span><br><span class="line"> i++;</span><br><span class="line"> }</span><br><span class="line"> }</span><br><span class="line"> }</span><br><span class="line">}</span><br></pre></td></tr></table></figure>]]></content>
<summary type="html"><p>重学<a href="https://www.youtube.com/watch?v=3IFxpozBs2I&amp;t=826s">KMP算法</a>,列出学习过程中我比较困惑的地方,给出前缀表的python实现</p></summary>
<category term="算法" scheme="https://walu.space/categories/%E7%AE%97%E6%B3%95/"/>
<category term="算法" scheme="https://walu.space/tags/%E7%AE%97%E6%B3%95/"/>
</entry>
<entry>
<title>测试代码</title>
<link href="https://walu.space/2023/06/11/%E6%B5%8B%E8%AF%95%E4%BB%A3%E7%A0%81/"/>
<id>https://walu.space/2023/06/11/%E6%B5%8B%E8%AF%95%E4%BB%A3%E7%A0%81/</id>
<published>2023-06-11T03:09:31.000Z</published>
<updated>2023-06-18T13:00:29.511Z</updated>
<content type="html"><![CDATA[<figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string"><stdio.h></span></span></span><br><span class="line"><span class="function"><span class="type">int</span> <span class="title">main</span><span class="params">(<span class="type">void</span>)</span></span></span><br><span class="line"><span class="function"></span>{</span><br><span class="line"> <span class="built_in">printf</span>(<span class="string">"Hello world\n"</span>);</span><br><span class="line">}</span><br></pre></td></tr></table></figure>]]></content>
<summary type="html"><figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="</summary>
<category term="TEST" scheme="https://walu.space/categories/TEST/"/>
<category term="TEST" scheme="https://walu.space/tags/TEST/"/>
</entry>
<entry>
<title>测试公式</title>
<link href="https://walu.space/2023/06/11/%E6%B5%8B%E8%AF%95%E5%85%AC%E5%BC%8F/"/>
<id>https://walu.space/2023/06/11/%E6%B5%8B%E8%AF%95%E5%85%AC%E5%BC%8F/</id>
<published>2023-06-11T01:37:45.000Z</published>
<updated>2023-06-18T14:21:16.460Z</updated>
<content type="html"><![CDATA[<!-- ![mafumafu](../image/1500x500.jpg "") --><p class="katex-block"><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mfrac><mn>1</mn><mn>22</mn></mfrac></mrow><annotation encoding="application/x-tex">\frac{1}{22}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:2.00744em;vertical-align:-0.686em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.32144em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">2</span><span class="mord">2</span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">1</span></span></span></span><span class="vlist-s"></span></span><span class="vlist-r"><span class="vlist" style="height:0.686em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span></span></span></span></span></p>]]></content>
<summary type="html"><!-- ![mafumafu](../image/1500x500.jpg "") -->
<p class="katex-block"><span class="katex-display"><span class="katex"><span class="katex-mat</summary>
<category term="TEST" scheme="https://walu.space/categories/TEST/"/>
<category term="TEST" scheme="https://walu.space/tags/TEST/"/>
</entry>
<entry>
<title>测试图片</title>
<link href="https://walu.space/2023/06/10/%E6%B5%8B%E8%AF%95%E5%9B%BE%E7%89%87/"/>
<id>https://walu.space/2023/06/10/%E6%B5%8B%E8%AF%95%E5%9B%BE%E7%89%87/</id>
<published>2023-06-10T15:37:45.000Z</published>
<updated>2023-06-18T14:21:22.459Z</updated>
<content type="html"><![CDATA[<p><img src="/2023/06/10/%E6%B5%8B%E8%AF%95%E5%9B%BE%E7%89%87/1500x500.jpg" alt></p>]]></content>
<summary type="html"><p><img src="/2023/06/10/%E6%B5%8B%E8%AF%95%E5%9B%BE%E7%89%87/1500x500.jpg" alt></p>
</summary>
<category term="TEST" scheme="https://walu.space/categories/TEST/"/>
<category term="TEST" scheme="https://walu.space/tags/TEST/"/>
</entry>
</feed>