From ce9064e9d397bf6b6c8ac50f5d0fc17033f190c8 Mon Sep 17 00:00:00 2001 From: krahets Date: Mon, 13 Feb 2023 16:26:27 +0800 Subject: [PATCH] build --- chapter_hashing/hash_map.md | 19 +++++++++---------- chapter_heap/heap.md | 2 +- index.md | 7 ++++++- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/chapter_hashing/hash_map.md b/chapter_hashing/hash_map.md index e64db248c..86c68ff43 100755 --- a/chapter_hashing/hash_map.md +++ b/chapter_hashing/hash_map.md @@ -311,18 +311,17 @@ comments: true ```javascript title="hash_map.js" /* 遍历哈希表 */ - // 遍历键值对 key->value - for (const entry of map.entries()) { - if (!entry) continue; - console.info(entry.key + ' -> ' + entry.val); + console.info('\n遍历键值对 Key->Value'); + for (const [k, v] of map.entries()) { + console.info(k + ' -> ' + v); } - // 单独遍历键 key - for (const key of map.keys()) { - console.info(key); + console.info('\n单独遍历键 Key'); + for (const k of map.keys()) { + console.info(k); } - // 单独遍历值 value - for (const val of map.values()) { - console.info(val); + console.info('\n单独遍历值 Value'); + for (const v of map.values()) { + console.info(v); } ``` diff --git a/chapter_heap/heap.md b/chapter_heap/heap.md index 1ebd6214f..8d9b5f146 100644 --- a/chapter_heap/heap.md +++ b/chapter_heap/heap.md @@ -1079,7 +1079,7 @@ comments: true ### 输入数据并建堆 * -如果我们想要直接输入一个列表并将其建堆,那么该怎么做呢?最直接地,考虑使用「元素入堆」方法,将列表元素依次入堆。元素入堆的时间复杂度为 $O(n)$ ,而平均长度为 $\frac{n}{2}$ ,因此该方法的总体时间复杂度为 $O(n \log n)$ 。 +如果我们想要直接输入一个列表并将其建堆,那么该怎么做呢?最直接地,考虑使用「元素入堆」方法,将列表元素依次入堆。元素入堆的时间复杂度为 $O(\log n)$ ,而平均长度为 $\frac{n}{2}$ ,因此该方法的总体时间复杂度为 $O(n \log n)$ 。 然而,存在一种更加优雅的建堆方法。设结点数量为 $n$ ,我们先将列表所有元素原封不动添加进堆,**然后迭代地对各个结点执行「从顶至底堆化」**。当然,**无需对叶结点执行堆化**,因为其没有子结点。 diff --git a/index.md b/index.md index f0637c1c7..ae7d57a55 100644 --- a/index.md +++ b/index.md @@ -58,6 +58,12 @@ hide:

推荐语

+!!! quote + + “如果我当年学数据结构与算法的时候有《Hello 算法》,学起来应该会简单10倍!” + + **—— 李沐,亚马逊资深首席科学家** + !!! quote “一本通俗易懂的数据结构与算法入门书,引导读者手脑并用地学习,强烈推荐算法初学者阅读。” @@ -79,7 +85,6 @@ hide:
-
justin-tse
justin-tse

JS / TS
krahets
krahets

Java / Python
nuomi1
nuomi1

Swift