Skip to content

Commit ac0da11

Browse files
authored
Bug fixes and improvements (krahets#1627)
* Update Copyright 2024 to 2025. * Fix the flex of .profile-cell for mobile devices. * Update performance_evaluation.md * 抛出 -> 给出 * Sync zh and zh-hant version. * Improve the landing page of the English version. * Bug fixes * Fix readme-typing-svg * Update readme-typing-svg * Bug fixes * sync zh and zh-hant versions.
1 parent 5dc9dd8 commit ac0da11

File tree

17 files changed

+112
-79
lines changed

17 files changed

+112
-79
lines changed

docs/chapter_computational_complexity/performance_evaluation.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
## 理论估算
2626

27-
由于实际测试具有较大的局限性,因此我们可以考虑仅通过一些计算来评估算法的效率。这种估算方法被称为<u>渐近复杂度分析(asymptotic complexity analysis)</u>,简称<u>复杂度分析</u>。
27+
由于实际测试具有较大的局限性,我们可以考虑仅通过一些计算来评估算法的效率。这种估算方法被称为<u>渐近复杂度分析(asymptotic complexity analysis)</u>,简称<u>复杂度分析</u>。
2828

2929
复杂度分析能够体现算法运行所需的时间和空间资源与输入数据大小之间的关系。**它描述了随着输入数据大小的增加,算法执行所需时间和空间的增长趋势**。这个定义有些拗口,我们可以将其分为三个重点来理解。
3030

docs/chapter_hashing/hash_algorithm.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ index = hash(key) % capacity
5252

5353
观察发现,每种哈希算法的最后一步都是对大质数 $1000000007$ 取模,以确保哈希值在合适的范围内。值得思考的是,为什么要强调对质数取模,或者说对合数取模的弊端是什么?这是一个有趣的问题。
5454

55-
先抛出结论**使用大质数作为模数,可以最大化地保证哈希值的均匀分布**。因为质数不与其他数字存在公约数,可以减少因取模操作而产生的周期性模式,从而避免哈希冲突。
55+
先给出结论**使用大质数作为模数,可以最大化地保证哈希值的均匀分布**。因为质数不与其他数字存在公约数,可以减少因取模操作而产生的周期性模式,从而避免哈希冲突。
5656

5757
举个例子,假设我们选择合数 $9$ 作为模数,它可以被 $3$ 整除,那么所有可以被 $3$ 整除的 `key` 都会被映射到 $0$、$3$、$6$ 这三个哈希值。
5858

docs/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ <h3>代码审阅者</h3>
349349
<h3>贡献者</h3>
350350
<p>本书在开源社区一百多位贡献者的共同努力下不断完善,感谢他们付出的时间与精力!</p>
351351
<a href="https://github.com/krahets/hello-algo/graphs/contributors">
352-
<img src="https://contrib.rocks/image?repo=krahets/hello-algo&max=300&columns=16" alt="Contributors" style="width: 100%; max-width: 38.5em;">
352+
<img src="https://contrib.rocks/image?repo=krahets/hello-algo&max=300&columns=12" alt="Contributors" style="width: 100%; max-width: 38.5em;">
353353
</a>
354354
</div>
355355
</div>

en/codes/python/chapter_stack_and_queue/linkedlist_deque.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def pop(self, is_front: bool) -> int:
6969
val: int = self._front.val # Temporarily store the head node value
7070
# Remove head node
7171
fnext: ListNode | None = self._front.next
72-
if fnext != None:
72+
if fnext is not None:
7373
fnext.prev = None
7474
self._front.next = None
7575
self._front = fnext # Update head node
@@ -78,7 +78,7 @@ def pop(self, is_front: bool) -> int:
7878
val: int = self._rear.val # Temporarily store the tail node value
7979
# Remove tail node
8080
rprev: ListNode | None = self._rear.prev
81-
if rprev != None:
81+
if rprev is not None:
8282
rprev.next = None
8383
self._rear.prev = None
8484
self._rear = rprev # Update tail node

en/docs/index.html

+15-15
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,23 @@
77
<img src="../assets/hero/links.png" alt="" style="position: absolute; width: auto; height: 78.751%; left: 10.545%; top: 7.326%;">
88
<a href="chapter_introduction/">
99
<img src="../assets/hero/astronaut.png" alt="" style="height: 46.673%; left: 35.413%; top: 24.343%;">
10-
<span style="left: 52.744%; top: 22.319%;">Encounter with Algorithms</span>
10+
<span style="left: 52.744%; top: 22.319%;">Encounter with Algos</span>
1111
</a>
1212
<a href="chapter_computational_complexity/">
1313
<img src="../assets/hero/chapter_computational_complexity.png" alt="" style="height: 12.347%; left: 36.267%; top: 37.653%;">
14-
<span style="left: 40.244%; top: 33.919%;">Complexity analysis</span>
14+
<span style="left: 36.244%; top: 34.919%;">Complexity analysis</span>
1515
</a>
1616
<a href="chapter_array_and_linkedlist/">
1717
<img src="../assets/hero/chapter_array_and_linkedlist.png" alt="" style="height: 22.242%; left: 73.242%; top: 52.481%;">
18-
<span style="left: 90.897%; top: 76.259%;">Array and linked list</span>
18+
<span style="left: 85.897%; top: 76.259%;">Array and linked list</span>
1919
</a>
2020
<a href="chapter_stack_and_queue/">
2121
<img src="../assets/hero/chapter_stack_and_queue.png" alt="" style="height: 14.302%; left: 62.646%; top: 77.875%;">
2222
<span style="left: 80.071%; top: 88.25%;">Stack and queue</span>
2323
</a>
2424
<a href="chapter_hashing/">
2525
<img src="../assets/hero/chapter_hashing.png" alt="" style="height: 15.266%; left: 63.281%; top: 27.933%;">
26-
<span style="left: 68.862%; top: 46.292%;">Hash table</span>
26+
<span style="left: 68.862%; top: 45.792%;">Hash table</span>
2727
</a>
2828
<a href="chapter_tree/">
2929
<img src="../assets/hero/chapter_tree.png" alt="" style="height: 19.615%; left: 80.137%; top: 26.678%;">
@@ -43,19 +43,19 @@
4343
</a>
4444
<a href="chapter_sorting/">
4545
<img src="../assets/hero/chapter_sorting.png" alt="" style="height: 9.574%; left: 25.409%; top: 40.747%;">
46-
<span style="left: 28.805%; top: 53.808%;">Sorting</span>
46+
<span style="left: 28.805%; top: 53.308%;">Sorting</span>
4747
</a>
4848
<a href="chapter_divide_and_conquer/">
4949
<img src="../assets/hero/chapter_divide_and_conquer.png" alt="" style="height: 18.681%; left: 32.721%; top: 4.816%;">
5050
<span style="left: 29.42%; top: 6.679%;">Divide and conquer</span>
5151
</a>
5252
<a href="chapter_backtracking/">
5353
<img src="../assets/hero/chapter_backtracking.png" alt="" style="height: 17.338%; left: 4.875%; top: 32.925%;">
54-
<span style="left: 4.742%; top: 50.113%;">Backtracking</span>
54+
<span style="left: 8.742%; top: 50.113%;">Backtracking</span>
5555
</a>
5656
<a href="chapter_dynamic_programming/">
5757
<img src="../assets/hero/chapter_dynamic_programming.png" alt="" style="height: 15.47%; left: 9.406%; top: 57.472%;">
58-
<span style="left: 8.561%; top: 75.351%;">Dynamic programming</span>
58+
<span style="left: 14.561%; top: 75.351%;">Dynamic programming</span>
5959
</a>
6060
<a href="chapter_greedy/">
6161
<img src="../assets/hero/chapter_greedy.png" alt="" style="height: 14.127%; left: 23.132%; top: 75.803%;">
@@ -65,7 +65,7 @@
6565

6666
<!-- heading -->
6767
<div class="heading-div">
68-
<img style="height: min(9vh, 12vw);" src="https://readme-typing-svg.demolab.com?font=Noto+Sans+SC&weight=400&duration=3500&pause=2000&color=21C8B8&center=true&vCenter=true&random=false&width=200&lines=Hello%2C+Algo+!" alt="" />
68+
<img style="height: min(9vh, 12vw);" src="https://readme-typing-svg.demolab.com/?font=Roboto&weight=400&duration=3500&pause=2000&color=FFF&center=true&vCenter=true&random=false&width=200&lines=Hello%2C+Algo!" alt="" />
6969
<div style="pointer-events: auto;">
7070
<p style="margin-top: max(-1vh, -2vw); margin-bottom: min(2vh, 3.5vw);">
7171
Data structures and algorithms crash course with animated illustrations and off-the-shelf code
@@ -113,7 +113,7 @@
113113
<img src="https://img.shields.io/badge/Dart-snow?logo=dart&logoColor=0175C2" alt="" />
114114
<img src="https://img.shields.io/badge/Zig-snow?logo=zig&logoColor=F7A41D" alt="" />
115115
</div>
116-
<p style="margin-top: 2em;">500 animated illustrations, 14 programming languages, and 3000 community Q&As to help you quickly get started with data structures and algorithms</p>
116+
<p style="margin-top: 2em;">500 animated illustrations, 14 programming languages, and 3000 community Q&As to help you dive into data structures and algorithms.</p>
117117
</div>
118118
</section>
119119

@@ -144,7 +144,7 @@
144144
<img class="device-on-hover" style="height: 66.31%;" src="../assets/hero/web_mac_iphone.png" alt="">
145145
<div style="height: 4.34%;"></div>
146146
<div class="text-button">
147-
<span>Read online</span>
147+
<span>Web</span>
148148
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 512">
149149
<path d="M278.6 233.4c12.5 12.5 12.5 32.8 0 45.3l-160 160c-12.5 12.5-32.8 12.5-45.3 0s-12.5-32.8 0-45.3L210.7 256 73.4 118.6c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0l160 160z" />
150150
</svg>
@@ -155,7 +155,7 @@
155155
<a href="https://github.com/krahets/hello-algo/releases">
156156
<img class="device-on-hover" style="height: 75%;" src="../assets/hero/pdf_ipad.png" alt="">
157157
<div class="text-button">
158-
<span>Download PDF</span>
158+
<span>PDF</span>
159159
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 512">
160160
<path d="M278.6 233.4c12.5 12.5 12.5 32.8 0 45.3l-160 160c-12.5 12.5-32.8 12.5-45.3 0s-12.5-32.8 0-45.3L210.7 256 73.4 118.6c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0l160 160z" />
161161
</svg>
@@ -195,7 +195,7 @@ <h3 style="text-align: center; margin: 1em auto;">Endorsements</h3>
195195
</svg>
196196
<h3 style="margin-left: 0.5em;">Animated illustrations</h3>
197197
</div>
198-
<p style="margin: 0;">It's crafted for ease of understanding, ensuring a smooth learning journey.</p>
198+
<p style="margin: 0;">Its crafted for a smooth learning experience.</p>
199199
<p class="intro-quote">"A picture is worth a thousand words."</p>
200200
</div>
201201
</div>
@@ -212,7 +212,7 @@ <h3 style="margin-left: 0.5em;">Animated illustrations</h3>
212212
</svg>
213213
<h3 style="margin-left: 0.5em;">Off-the-shelf code</h3>
214214
</div>
215-
<p style="margin: 0;">Featuring multiple programming languages, all runnable with a single click.</p>
215+
<p style="margin: 0;">One click to run code in multiple languages.</p>
216216
<p class="intro-quote">"Talk is cheap. Show me the code."</p>
217217
</div>
218218
</div>
@@ -227,7 +227,7 @@ <h3 style="margin-left: 0.5em;">Off-the-shelf code</h3>
227227
</svg>
228228
<h3 style="margin-left: 0.5em;">Learning together</h3>
229229
</div>
230-
<p style="margin: 0;">Welcome discussions and questions with open arms.</p>
230+
<p style="margin: 0;">Don’t hesitate to ask or share your thoughts.</p>
231231
<p class="intro-quote">"Learning by teaching."</p>
232232
</div>
233233
</div>
@@ -416,7 +416,7 @@ <h3>English version reviewers</h3>
416416
<h3>Contributors</h3>
417417
<p>This book has been refined by the efforts of over 180 contributors. We sincerely thank them for their invaluable time and contributions!</p>
418418
<a href="https://github.com/krahets/hello-algo/graphs/contributors">
419-
<img src="https://contrib.rocks/image?repo=krahets/hello-algo&max=300&columns=16" alt="Contributors" style="width: 100%; max-width: 38.5em;">
419+
<img src="https://contrib.rocks/image?repo=krahets/hello-algo&max=300&columns=12" alt="Contributors" style="width: 100%; max-width: 38.5em;">
420420
</a>
421421
</div>
422422
</div>

mkdocs.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ edit_uri: tree/main/docs
1212
version: 1.2.0
1313

1414
# Copyright
15-
copyright: Copyright &copy; 2024 krahets<br>The website content is licensed under <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/">CC BY-NC-SA 4.0</a>
15+
copyright: Copyright &copy; 2025 krahets<br>The website content is licensed under <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/">CC BY-NC-SA 4.0</a>
1616

1717
# Configuration
1818
theme:

overrides/stylesheets/extra.css

+39-26
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* Color Settings */
22
/* https://github.com/squidfunk/mkdocs-material/blob/6b5035f5580f97532d664e3d1babf5f320e88ee9/src/assets/stylesheets/main/_colors.scss */
33
/* https://squidfunk.github.io/mkdocs-material/setup/changing-the-colors/#custom-colors */
4-
:root > * {
4+
:root>* {
55
--md-primary-fg-color: #ffffff;
66
--md-primary-bg-color: #1d1d20;
77

@@ -69,8 +69,10 @@
6969
.md-header--landing {
7070
box-shadow: none;
7171
transition: none;
72-
backdrop-filter: saturate(180%) blur(20px); /* Gaussian blur */
73-
-webkit-backdrop-filter: saturate(180%) blur(20px); /* Safari */
72+
backdrop-filter: saturate(180%) blur(20px);
73+
/* Gaussian blur */
74+
-webkit-backdrop-filter: saturate(180%) blur(20px);
75+
/* Safari */
7476
background-color: var(--md-header-bg-color);
7577
}
7678

@@ -159,7 +161,7 @@ body {
159161

160162
/* max height of code block */
161163
/* https://github.com/squidfunk/mkdocs-material/issues/3444 */
162-
.md-typeset pre > code {
164+
.md-typeset pre>code {
163165
max-height: 25rem;
164166
}
165167

@@ -176,7 +178,8 @@ body {
176178
align-items: center;
177179
justify-content: center;
178180
margin: 0 auto;
179-
width: 100%; /* Default to full width */
181+
width: 100%;
182+
/* Default to full width */
180183
}
181184

182185
/* Admonition for python tutor */
@@ -192,12 +195,13 @@ body {
192195
box-shadow: var(--md-shadow-z1);
193196
}
194197

195-
.md-typeset .pythontutor > .admonition-title,
196-
.md-typeset .pythontutor > summary {
198+
.md-typeset .pythontutor>.admonition-title,
199+
.md-typeset .pythontutor>summary {
197200
background-color: var(--md-code-bg-color);
198201
}
199-
.md-typeset .pythontutor > .admonition-title::before,
200-
.md-typeset .pythontutor > summary::before {
202+
203+
.md-typeset .pythontutor>.admonition-title::before,
204+
.md-typeset .pythontutor>summary::before {
201205
background-color: rgb(55, 118, 171);
202206
-webkit-mask-image: var(--md-admonition-icon--pythontutor);
203207
mask-image: var(--md-admonition-icon--pythontutor);
@@ -301,7 +305,7 @@ body {
301305

302306
a:hover .device-on-hover {
303307
filter: drop-shadow(0 0 0.2rem rgba(0, 0, 0, 0.15));
304-
transform: scale(1.02);
308+
transform: scale(1.01);
305309
}
306310

307311
/* text button */
@@ -363,27 +367,27 @@ a:hover .text-button span {
363367
}
364368

365369
/* hover on the planets */
366-
.hero-div > a > img {
370+
.hero-div>a>img {
367371
width: auto;
368372
position: absolute;
369373
transition: transform 0.3s ease-in-out, filter 0.3s ease-in-out;
370374
}
371375

372-
.hero-div > a > span {
376+
.hero-div>a>span {
373377
margin: 0;
374378
position: absolute;
375379
transform: translateX(-50%) translateY(-50%);
376-
white-space: nowrap; /* prevent line breaks */
380+
white-space: nowrap;
381+
/* prevent line breaks */
377382
color: white;
378383
}
379384

380-
.hero-div > a:hover > img {
381-
filter: brightness(1.15) saturate(1.1)
382-
drop-shadow(0 0 0.5rem rgba(255, 255, 255, 0.2));
385+
.hero-div>a:hover>img {
386+
filter: brightness(1.15) saturate(1.1) drop-shadow(0 0 0.5rem rgba(255, 255, 255, 0.2));
383387
transform: scale(1.03);
384388
}
385389

386-
.hero-div > a:hover > span {
390+
.hero-div>a:hover>span {
387391
text-decoration: underline;
388392
color: var(--md-typeset-btn-color);
389393
}
@@ -420,13 +424,14 @@ a:hover .text-button span {
420424
.intro-image {
421425
flex-shrink: 0;
422426
flex-grow: 0;
423-
width: 55%;
427+
width: 50%;
424428
border-radius: 0.5em;
425429
box-shadow: var(--md-shadow-z2);
426430
}
427431

428432
.intro-text {
429-
flex-grow: 1; /* fill the space */
433+
flex-grow: 1;
434+
/* fill the space */
430435
display: flex;
431436
flex-direction: column;
432437
justify-content: center;
@@ -436,7 +441,7 @@ a:hover .text-button span {
436441
margin: 2em;
437442
}
438443

439-
.intro-text > div {
444+
.intro-text>div {
440445
align-self: flex-start;
441446
width: auto;
442447
margin: 0 auto;
@@ -461,9 +466,8 @@ a:hover .text-button span {
461466
}
462467

463468
.profile-cell {
464-
flex: 1; /* even distribution */
465-
flex-basis: 20%;
466-
margin: 1em 0.5em;
469+
flex: 1 1 15%;
470+
margin: 1em 0;
467471
text-align: center;
468472
}
469473

@@ -494,12 +498,16 @@ a:hover .text-button span {
494498
}
495499
}
496500

497-
/* Hide table of contents */
501+
/* mobile devices */
498502
@media screen and (max-width: 60em) {
499503
.home-div {
500504
font-size: 0.75rem;
501505
}
502506

507+
.hero-div {
508+
margin-top: -4rem;
509+
}
510+
503511
.intro-container {
504512
flex-direction: column;
505513
}
@@ -524,11 +532,16 @@ a:hover .text-button span {
524532
.text-button {
525533
margin: 0.7em auto;
526534
}
535+
536+
.profile-cell {
537+
flex: 1 1 30%;
538+
}
527539
}
528540

529541
.video-container {
530542
position: relative;
531-
padding-bottom: 56.25%; /* 16:9 */
543+
padding-bottom: 56.25%;
544+
/* 16:9 */
532545
height: 0;
533546
}
534547

@@ -538,4 +551,4 @@ a:hover .text-button span {
538551
left: 0;
539552
width: 100%;
540553
height: 100%;
541-
}
554+
}

zh-hant/codes/python/chapter_stack_and_queue/linkedlist_deque.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def pop(self, is_front: bool) -> int:
6969
val: int = self._front.val # 暫存頭節點值
7070
# 刪除頭節點
7171
fnext: ListNode | None = self._front.next
72-
if fnext != None:
72+
if fnext is not None:
7373
fnext.prev = None
7474
self._front.next = None
7575
self._front = fnext # 更新頭節點
@@ -78,7 +78,7 @@ def pop(self, is_front: bool) -> int:
7878
val: int = self._rear.val # 暫存尾節點值
7979
# 刪除尾節點
8080
rprev: ListNode | None = self._rear.prev
81-
if rprev != None:
81+
if rprev is not None:
8282
rprev.next = None
8383
self._rear.prev = None
8484
self._rear = rprev # 更新尾節點

0 commit comments

Comments
 (0)