deploy
BIN
.DS_Store
vendored
Before Width: | Height: | Size: 85 KiB |
Before Width: | Height: | Size: 57 KiB |
BIN
chapter_hashing/hash_collision.assets/hash_table_chaining.png
Normal file
After Width: | Height: | Size: 90 KiB |
After Width: | Height: | Size: 67 KiB |
|
@ -2140,18 +2140,17 @@
|
||||||
|
|
||||||
<h1 id="62">6.2. 哈希冲突<a class="headerlink" href="#62" title="Permanent link">¶</a></h1>
|
<h1 id="62">6.2. 哈希冲突<a class="headerlink" href="#62" title="Permanent link">¶</a></h1>
|
||||||
<p>在理想情况下,哈希函数为每个输入生成唯一的输出,实现 key 和数组索引的一一对应。但实际上,<strong>哈希函数的输入空间通常远大于输出空间</strong>,因此多个输入产生相同输出的情况是不可避免的。例如,输入空间为全体整数,输出空间为数组容量大小,则必然有多个整数映射至同一数组索引。</p>
|
<p>在理想情况下,哈希函数为每个输入生成唯一的输出,实现 key 和数组索引的一一对应。但实际上,<strong>哈希函数的输入空间通常远大于输出空间</strong>,因此多个输入产生相同输出的情况是不可避免的。例如,输入空间为全体整数,输出空间为数组容量大小,则必然有多个整数映射至同一数组索引。</p>
|
||||||
<p>这种多个输入对应同一输出索引的现象被称为「哈希冲突 Hash Collision」。哈希冲突会导致查询结果错误,严重影响哈希表的可用性。哈希冲突的解决方法主要有两种:</p>
|
<p>这种多个输入对应同一输出索引的现象被称为「哈希冲突 Hash Collision」。哈希冲突会导致查询结果错误,严重影响哈希表的可用性。哈希冲突的处理方法主要有两种:</p>
|
||||||
<ul>
|
<ul>
|
||||||
<li><strong>扩大哈希表容量</strong>:哈希表容量越大,键值对聚集的概率就越低。极端情况下,当输入空间和输出空间大小相等时,哈希表等同于数组,每个 key 都对应唯一的数组索引。</li>
|
<li><strong>扩大哈希表容量</strong>:哈希表容量越大,键值对聚集的概率就越低。极端情况下,当输入空间和输出空间大小相等时,哈希表等同于数组,每个 key 都对应唯一的数组索引。</li>
|
||||||
<li><strong>优化哈希表结构</strong>:常用方法包括链式地址和开放寻址。</li>
|
<li><strong>优化哈希表结构</strong>:常用方法包括链式地址和开放寻址。这类方法的思路是通过改良数据结构,使得哈希表可以在发生哈希冲突时仍然可以正常工作。当然,这些优化往往是以牺牲时间效率为代价的。</li>
|
||||||
</ul>
|
</ul>
|
||||||
<h2 id="621">6.2.1. 哈希表扩容<a class="headerlink" href="#621" title="Permanent link">¶</a></h2>
|
<h2 id="621">6.2.1. 哈希表扩容<a class="headerlink" href="#621" title="Permanent link">¶</a></h2>
|
||||||
<p>哈希函数的最后一步通常是对桶数量 <span class="arithmatex">\(n\)</span> 取余,作用是将哈希值映射到桶索引范围,从而将 key 放入对应的桶中。当哈希表容量越大(即 <span class="arithmatex">\(n\)</span> 越大)时,多个 key 被分配到同一个桶中的概率就越低,冲突就越少。</p>
|
<p>哈希函数的最后一步通常是对桶数量 <span class="arithmatex">\(n\)</span> 取余,作用是将哈希值映射到桶索引范围,从而将 key 放入对应的桶中。当哈希表容量越大(即 <span class="arithmatex">\(n\)</span> 越大)时,多个 key 被分配到同一个桶中的概率就越低,冲突就越少。因此,<strong>当哈希表内的冲突总体较为严重时,编程语言通常通过扩容哈希表来缓解冲突</strong>。类似于数组扩容,哈希表扩容需将所有键值对从原哈希表迁移至新哈希表,开销较大。</p>
|
||||||
<p>因此,<strong>当哈希表内的冲突总体较为严重时,编程语言通常通过扩容哈希表来缓解冲突</strong>。类似于数组扩容,哈希表扩容需将所有键值对从原哈希表迁移至新哈希表,开销较大。</p>
|
|
||||||
<p>编程语言通常使用「负载因子 Load Factor」来衡量哈希冲突的严重程度,<strong>定义为哈希表中元素数量除以桶数量</strong>,常作为哈希表扩容的触发条件。在 Java 中,当负载因子超过 <span class="arithmatex">\(0.75\)</span> 时,系统会将 HashMap 容量扩展为原先的 <span class="arithmatex">\(2\)</span> 倍。</p>
|
<p>编程语言通常使用「负载因子 Load Factor」来衡量哈希冲突的严重程度,<strong>定义为哈希表中元素数量除以桶数量</strong>,常作为哈希表扩容的触发条件。在 Java 中,当负载因子超过 <span class="arithmatex">\(0.75\)</span> 时,系统会将 HashMap 容量扩展为原先的 <span class="arithmatex">\(2\)</span> 倍。</p>
|
||||||
<h2 id="622">6.2.2. 链式地址<a class="headerlink" href="#622" title="Permanent link">¶</a></h2>
|
<h2 id="622">6.2.2. 链式地址<a class="headerlink" href="#622" title="Permanent link">¶</a></h2>
|
||||||
<p>在原始哈希表中,每个桶仅能存储一个键值对。「链式地址 Separate Chaining」将单个元素转换为链表,将键值对作为链表节点,将所有发生冲突的键值对都存储在同一链表中。</p>
|
<p>在原始哈希表中,每个桶仅能存储一个键值对。「链式地址 Separate Chaining」将单个元素转换为链表,将键值对作为链表节点,将所有发生冲突的键值对都存储在同一链表中。</p>
|
||||||
<p><img alt="链式地址哈希表" src="../hash_collision.assets/hash_collision_chaining.png" /></p>
|
<p><img alt="链式地址哈希表" src="../hash_collision.assets/hash_table_chaining.png" /></p>
|
||||||
<p align="center"> Fig. 链式地址哈希表 </p>
|
<p align="center"> Fig. 链式地址哈希表 </p>
|
||||||
|
|
||||||
<p>链式地址下,哈希表的操作方法包括:</p>
|
<p>链式地址下,哈希表的操作方法包括:</p>
|
||||||
|
@ -2160,7 +2159,7 @@
|
||||||
<li><strong>添加元素</strong>:先通过哈希函数访问链表头节点,然后将节点(即键值对)添加到链表中。</li>
|
<li><strong>添加元素</strong>:先通过哈希函数访问链表头节点,然后将节点(即键值对)添加到链表中。</li>
|
||||||
<li><strong>删除元素</strong>:根据哈希函数的结果访问链表头部,接着遍历链表以查找目标节点,并将其删除。</li>
|
<li><strong>删除元素</strong>:根据哈希函数的结果访问链表头部,接着遍历链表以查找目标节点,并将其删除。</li>
|
||||||
</ul>
|
</ul>
|
||||||
<p>尽管链式地址法解决了哈希冲突问题,但仍存在一些局限性,包括:</p>
|
<p>该方法存在一些局限性,包括:</p>
|
||||||
<ul>
|
<ul>
|
||||||
<li><strong>占用空间增大</strong>,由于链表或二叉树包含节点指针,相比数组更加耗费内存空间;</li>
|
<li><strong>占用空间增大</strong>,由于链表或二叉树包含节点指针,相比数组更加耗费内存空间;</li>
|
||||||
<li><strong>查询效率降低</strong>,因为需要线性遍历链表来查找对应元素;</li>
|
<li><strong>查询效率降低</strong>,因为需要线性遍历链表来查找对应元素;</li>
|
||||||
|
@ -2551,14 +2550,14 @@
|
||||||
<p>为了提高效率,<strong>我们可以将链表转换为「AVL 树」或「红黑树」</strong>,从而将查询操作的时间复杂度优化至 <span class="arithmatex">\(O(\log n)\)</span> 。</p>
|
<p>为了提高效率,<strong>我们可以将链表转换为「AVL 树」或「红黑树」</strong>,从而将查询操作的时间复杂度优化至 <span class="arithmatex">\(O(\log n)\)</span> 。</p>
|
||||||
</div>
|
</div>
|
||||||
<h2 id="623">6.2.3. 开放寻址<a class="headerlink" href="#623" title="Permanent link">¶</a></h2>
|
<h2 id="623">6.2.3. 开放寻址<a class="headerlink" href="#623" title="Permanent link">¶</a></h2>
|
||||||
<p>「开放寻址 Open Addressing」不引入额外的数据结构,而是通过“多次探测”来解决哈希冲突,探测方式主要包括线性探测、平方探测、多次哈希。</p>
|
<p>「开放寻址 Open Addressing」不引入额外的数据结构,而是通过“多次探测”来处理哈希冲突,探测方式主要包括线性探测、平方探测、多次哈希。</p>
|
||||||
<h3 id="_1">线性探测<a class="headerlink" href="#_1" title="Permanent link">¶</a></h3>
|
<h3 id="_1">线性探测<a class="headerlink" href="#_1" title="Permanent link">¶</a></h3>
|
||||||
<p>线性探测采用固定步长的线性查找来解决哈希冲突。</p>
|
<p>线性探测采用固定步长的线性查找来进行探测,对应的哈希表操作方法为:</p>
|
||||||
<ul>
|
<ul>
|
||||||
<li><strong>插入元素</strong>:通过哈希函数计算数组索引,若发现桶内已有元素,则从冲突位置向后线性遍历(步长通常为 <span class="arithmatex">\(1\)</span> ),直至找到空位,将元素插入其中。</li>
|
<li><strong>插入元素</strong>:通过哈希函数计算数组索引,若发现桶内已有元素,则从冲突位置向后线性遍历(步长通常为 <span class="arithmatex">\(1\)</span> ),直至找到空位,将元素插入其中。</li>
|
||||||
<li><strong>查找元素</strong>:若发现哈希冲突,则使用相同步长向后线性遍历,直到找到对应元素,返回 value 即可;或者若遇到空位,说明目标键值对不在哈希表中,返回 <span class="arithmatex">\(\text{None}\)</span> 。</li>
|
<li><strong>查找元素</strong>:若发现哈希冲突,则使用相同步长向后线性遍历,直到找到对应元素,返回 value 即可;或者若遇到空位,说明目标键值对不在哈希表中,返回 <span class="arithmatex">\(\text{None}\)</span> 。</li>
|
||||||
</ul>
|
</ul>
|
||||||
<p><img alt="线性探测" src="../hash_collision.assets/hash_collision_linear_probing.png" /></p>
|
<p><img alt="线性探测" src="../hash_collision.assets/hash_table_linear_probing.png" /></p>
|
||||||
<p align="center"> Fig. 线性探测 </p>
|
<p align="center"> Fig. 线性探测 </p>
|
||||||
|
|
||||||
<p>然而,线性探测存在以下缺陷:</p>
|
<p>然而,线性探测存在以下缺陷:</p>
|
||||||
|
|
Before Width: | Height: | Size: 79 KiB After Width: | Height: | Size: 90 KiB |
Before Width: | Height: | Size: 88 KiB After Width: | Height: | Size: 98 KiB |
Before Width: | Height: | Size: 65 KiB |
BIN
chapter_hashing/hash_map.assets/hash_table_lookup.png
Normal file
After Width: | Height: | Size: 60 KiB |
|
@ -1021,7 +1021,7 @@
|
||||||
|
|
||||||
<li class="md-nav__item">
|
<li class="md-nav__item">
|
||||||
<a href="#612" class="md-nav__link">
|
<a href="#612" class="md-nav__link">
|
||||||
6.1.2. 哈希函数
|
6.1.2. 哈希表简单实现
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
</li>
|
</li>
|
||||||
|
@ -2063,7 +2063,7 @@
|
||||||
|
|
||||||
<li class="md-nav__item">
|
<li class="md-nav__item">
|
||||||
<a href="#612" class="md-nav__link">
|
<a href="#612" class="md-nav__link">
|
||||||
6.1.2. 哈希函数
|
6.1.2. 哈希表简单实现
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
</li>
|
</li>
|
||||||
|
@ -2099,9 +2099,9 @@
|
||||||
|
|
||||||
|
|
||||||
<h1 id="61">6.1. 哈希表<a class="headerlink" href="#61" title="Permanent link">¶</a></h1>
|
<h1 id="61">6.1. 哈希表<a class="headerlink" href="#61" title="Permanent link">¶</a></h1>
|
||||||
<p>哈希表通过建立「键 key」与「值 value」之间的映射,实现高效的元素查询。具体而言,我们向哈希表输入一个 key,则可以在 <span class="arithmatex">\(O(1)\)</span> 时间内获取对应的 value 。</p>
|
<p>「哈希表 Hash Table」通过建立键 <code>key</code> 与值 <code>value</code> 之间的映射,实现高效的元素查询。具体而言,我们向哈希表输入一个 <code>key</code> ,则可以在 <span class="arithmatex">\(O(1)\)</span> 时间内获取对应的 <code>value</code> 。</p>
|
||||||
<p>以一个包含 <span class="arithmatex">\(n\)</span> 个学生的数据库为例,每个学生都有“姓名 <code>name</code>”和“学号 <code>id</code>”两项数据。假如我们希望实现查询功能,例如“输入一个学号,返回对应的姓名”,则可以采用哈希表来实现。</p>
|
<p>以一个包含 <span class="arithmatex">\(n\)</span> 个学生的数据库为例,每个学生都有“姓名 <code>name</code>”和“学号 <code>id</code>”两项数据。假如我们希望实现查询功能,例如“输入一个学号,返回对应的姓名”,则可以采用哈希表来实现。</p>
|
||||||
<p><img alt="哈希表的抽象表示" src="../hash_map.assets/hash_map.png" /></p>
|
<p><img alt="哈希表的抽象表示" src="../hash_map.assets/hash_table_lookup.png" /></p>
|
||||||
<p align="center"> Fig. 哈希表的抽象表示 </p>
|
<p align="center"> Fig. 哈希表的抽象表示 </p>
|
||||||
|
|
||||||
<p>除哈希表外,我们还可以使用数组或链表实现元素查询,其中:</p>
|
<p>除哈希表外,我们还可以使用数组或链表实现元素查询,其中:</p>
|
||||||
|
@ -2110,7 +2110,6 @@
|
||||||
<li>添加元素仅需添加至尾部即可,使用 <span class="arithmatex">\(O(1)\)</span> 时间;</li>
|
<li>添加元素仅需添加至尾部即可,使用 <span class="arithmatex">\(O(1)\)</span> 时间;</li>
|
||||||
<li>删除元素需要先查询再删除,使用 <span class="arithmatex">\(O(n)\)</span> 时间;</li>
|
<li>删除元素需要先查询再删除,使用 <span class="arithmatex">\(O(n)\)</span> 时间;</li>
|
||||||
</ul>
|
</ul>
|
||||||
<p>然而,在哈希表中进行增删查的时间复杂度都是 <span class="arithmatex">\(O(1)\)</span> 。哈希表全面胜出!因此,哈希表常用于对查找效率要求较高的场景。</p>
|
|
||||||
<div class="center-table">
|
<div class="center-table">
|
||||||
<table>
|
<table>
|
||||||
<thead>
|
<thead>
|
||||||
|
@ -2143,6 +2142,7 @@
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
<p>观察发现,在哈希表中进行增删查改的时间复杂度都是 <span class="arithmatex">\(O(1)\)</span> ,非常高效。因此,哈希表常用于对查找效率要求较高的场景。</p>
|
||||||
<h2 id="611">6.1.1. 哈希表常用操作<a class="headerlink" href="#611" title="Permanent link">¶</a></h2>
|
<h2 id="611">6.1.1. 哈希表常用操作<a class="headerlink" href="#611" title="Permanent link">¶</a></h2>
|
||||||
<p>哈希表的基本操作包括 <strong>初始化、查询操作、添加与删除键值对</strong>。</p>
|
<p>哈希表的基本操作包括 <strong>初始化、查询操作、添加与删除键值对</strong>。</p>
|
||||||
<div class="tabbed-set tabbed-alternate" data-tabs="1:11"><input checked="checked" id="__tabbed_1_1" name="__tabbed_1" type="radio" /><input id="__tabbed_1_2" name="__tabbed_1" type="radio" /><input id="__tabbed_1_3" name="__tabbed_1" type="radio" /><input id="__tabbed_1_4" name="__tabbed_1" type="radio" /><input id="__tabbed_1_5" name="__tabbed_1" type="radio" /><input id="__tabbed_1_6" name="__tabbed_1" type="radio" /><input id="__tabbed_1_7" name="__tabbed_1" type="radio" /><input id="__tabbed_1_8" name="__tabbed_1" type="radio" /><input id="__tabbed_1_9" name="__tabbed_1" type="radio" /><input id="__tabbed_1_10" name="__tabbed_1" type="radio" /><input id="__tabbed_1_11" name="__tabbed_1" type="radio" /><div class="tabbed-labels"><label for="__tabbed_1_1">Java</label><label for="__tabbed_1_2">C++</label><label for="__tabbed_1_3">Python</label><label for="__tabbed_1_4">Go</label><label for="__tabbed_1_5">JavaScript</label><label for="__tabbed_1_6">TypeScript</label><label for="__tabbed_1_7">C</label><label for="__tabbed_1_8">C#</label><label for="__tabbed_1_9">Swift</label><label for="__tabbed_1_10">Zig</label><label for="__tabbed_1_11">Dart</label></div>
|
<div class="tabbed-set tabbed-alternate" data-tabs="1:11"><input checked="checked" id="__tabbed_1_1" name="__tabbed_1" type="radio" /><input id="__tabbed_1_2" name="__tabbed_1" type="radio" /><input id="__tabbed_1_3" name="__tabbed_1" type="radio" /><input id="__tabbed_1_4" name="__tabbed_1" type="radio" /><input id="__tabbed_1_5" name="__tabbed_1" type="radio" /><input id="__tabbed_1_6" name="__tabbed_1" type="radio" /><input id="__tabbed_1_7" name="__tabbed_1" type="radio" /><input id="__tabbed_1_8" name="__tabbed_1" type="radio" /><input id="__tabbed_1_9" name="__tabbed_1" type="radio" /><input id="__tabbed_1_10" name="__tabbed_1" type="radio" /><input id="__tabbed_1_11" name="__tabbed_1" type="radio" /><div class="tabbed-labels"><label for="__tabbed_1_1">Java</label><label for="__tabbed_1_2">C++</label><label for="__tabbed_1_3">Python</label><label for="__tabbed_1_4">Go</label><label for="__tabbed_1_5">JavaScript</label><label for="__tabbed_1_6">TypeScript</label><label for="__tabbed_1_7">C</label><label for="__tabbed_1_8">C#</label><label for="__tabbed_1_9">Swift</label><label for="__tabbed_1_10">Zig</label><label for="__tabbed_1_11">Dart</label></div>
|
||||||
|
@ -2508,23 +2508,19 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<h2 id="612">6.1.2. 哈希函数<a class="headerlink" href="#612" title="Permanent link">¶</a></h2>
|
<h2 id="612">6.1.2. 哈希表简单实现<a class="headerlink" href="#612" title="Permanent link">¶</a></h2>
|
||||||
<p>哈希表的底层实现为数组,同时可能包含链表、二叉树(红黑树)等数据结构,以提高查询性能(将在下节讨论)。</p>
|
<p>我们先考虑最简单的情况,<strong>仅用一个数组来实现哈希表</strong>。在哈希表中,我们通常将数组中的每个空位称为「桶 Bucket」,每个桶可存储一个键值对。因此,查询操作就是定位输入的 <code>key</code> 对应的桶,从而得到 <code>value</code> 。</p>
|
||||||
<p>首先考虑最简单的情况,<strong>仅使用一个数组来实现哈希表</strong>。通常,我们将数组中的每个空位称为「桶 Bucket」,用于存储键值对。</p>
|
<p>那么,如何基于 <code>key</code> 来定位对应的桶呢?这是通过「哈希函数 Hash Function」实现的。哈希函数的作用是将一个较大的输入空间映射到一个较小的输出空间。在哈希表中,输入空间是所有 <code>key</code> ,输出空间是所有桶(数组索引)。换句话说,<strong>输入一个 <code>key</code> ,我们可以通过哈希函数得到该 <code>key</code> 对应的键值对存储在数组中的位置</strong>。</p>
|
||||||
<p>我们将键值对 key, value 封装成一个类 <code>Pair</code> ,并将所有 <code>Pair</code> 放入数组中。这样,数组中的每个 <code>Pair</code> 都具有唯一的索引。为了建立 key 和索引之间的映射关系,我们需要使用「哈希函数 Hash Function」。</p>
|
<p>哈希函数的计算过程分为两步:输入一个 <code>key</code> ,首先通过函数 <code>hash(key)</code> 计算得到哈希值,接下来将哈希值对桶数量(数组长度)取模,从而获取该 <code>key</code> 对应的数组索引 <code>index</code> 。计算公式如下</p>
|
||||||
<p>设哈希表的数组为 <code>buckets</code> ,哈希函数为 <code>f(x)</code> ,那么查询操作的步骤如下:</p>
|
|
||||||
<ol>
|
|
||||||
<li>输入 <code>key</code> ,通过哈希函数计算出索引 <code>index</code> ,即 <code>index = f(key)</code> ;</li>
|
|
||||||
<li>通过索引在数组中访问到键值对 <code>pair</code> ,即 <code>pair = buckets[index]</code> ,然后从 <code>pair</code> 中获取对应的 <code>value</code> ;</li>
|
|
||||||
</ol>
|
|
||||||
<p>以学生数据 <code>key 学号 -> value 姓名</code> 为例,我们可以设计如下哈希函数:</p>
|
|
||||||
<div class="arithmatex">\[
|
<div class="arithmatex">\[
|
||||||
f(x) = x \bmod {100}
|
index = \text{hash}(key) \bmod {c}
|
||||||
\]</div>
|
\]</div>
|
||||||
<p>其中 <span class="arithmatex">\(\bmod\)</span> 表示取余运算。</p>
|
<p>其中, <span class="arithmatex">\(\bmod\)</span> 表示取余运算, <span class="arithmatex">\(c\)</span> 为桶数量(数组长度)。随后,我们就可以利用 <code>index</code> 在哈希表中访问对应的桶,从而获取 <code>value</code> 。</p>
|
||||||
|
<p>设数组长度 <span class="arithmatex">\(c = 100\)</span> , <span class="arithmatex">\(\text{hash}(key) = key\)</span> ,易得哈希函数为 <span class="arithmatex">\(key \bmod 100\)</span> 。下图以 <code>key</code> 学号和 <code>value</code> 姓名为例,展示了哈希函数的工作原理。</p>
|
||||||
<p><img alt="哈希函数工作原理" src="../hash_map.assets/hash_function.png" /></p>
|
<p><img alt="哈希函数工作原理" src="../hash_map.assets/hash_function.png" /></p>
|
||||||
<p align="center"> Fig. 哈希函数工作原理 </p>
|
<p align="center"> Fig. 哈希函数工作原理 </p>
|
||||||
|
|
||||||
|
<p>以下代码给出了一个简单哈希表实现。其中,我们将 <code>key</code> 和 <code>value</code> 封装成一个类 <code>Pair</code> ,以表示键值对。</p>
|
||||||
<div class="tabbed-set tabbed-alternate" data-tabs="3:11"><input checked="checked" id="__tabbed_3_1" name="__tabbed_3" type="radio" /><input id="__tabbed_3_2" name="__tabbed_3" type="radio" /><input id="__tabbed_3_3" name="__tabbed_3" type="radio" /><input id="__tabbed_3_4" name="__tabbed_3" type="radio" /><input id="__tabbed_3_5" name="__tabbed_3" type="radio" /><input id="__tabbed_3_6" name="__tabbed_3" type="radio" /><input id="__tabbed_3_7" name="__tabbed_3" type="radio" /><input id="__tabbed_3_8" name="__tabbed_3" type="radio" /><input id="__tabbed_3_9" name="__tabbed_3" type="radio" /><input id="__tabbed_3_10" name="__tabbed_3" type="radio" /><input id="__tabbed_3_11" name="__tabbed_3" type="radio" /><div class="tabbed-labels"><label for="__tabbed_3_1">Java</label><label for="__tabbed_3_2">C++</label><label for="__tabbed_3_3">Python</label><label for="__tabbed_3_4">Go</label><label for="__tabbed_3_5">JavaScript</label><label for="__tabbed_3_6">TypeScript</label><label for="__tabbed_3_7">C</label><label for="__tabbed_3_8">C#</label><label for="__tabbed_3_9">Swift</label><label for="__tabbed_3_10">Zig</label><label for="__tabbed_3_11">Dart</label></div>
|
<div class="tabbed-set tabbed-alternate" data-tabs="3:11"><input checked="checked" id="__tabbed_3_1" name="__tabbed_3" type="radio" /><input id="__tabbed_3_2" name="__tabbed_3" type="radio" /><input id="__tabbed_3_3" name="__tabbed_3" type="radio" /><input id="__tabbed_3_4" name="__tabbed_3" type="radio" /><input id="__tabbed_3_5" name="__tabbed_3" type="radio" /><input id="__tabbed_3_6" name="__tabbed_3" type="radio" /><input id="__tabbed_3_7" name="__tabbed_3" type="radio" /><input id="__tabbed_3_8" name="__tabbed_3" type="radio" /><input id="__tabbed_3_9" name="__tabbed_3" type="radio" /><input id="__tabbed_3_10" name="__tabbed_3" type="radio" /><input id="__tabbed_3_11" name="__tabbed_3" type="radio" /><div class="tabbed-labels"><label for="__tabbed_3_1">Java</label><label for="__tabbed_3_2">C++</label><label for="__tabbed_3_3">Python</label><label for="__tabbed_3_4">Go</label><label for="__tabbed_3_5">JavaScript</label><label for="__tabbed_3_6">TypeScript</label><label for="__tabbed_3_7">C</label><label for="__tabbed_3_8">C#</label><label for="__tabbed_3_9">Swift</label><label for="__tabbed_3_10">Zig</label><label for="__tabbed_3_11">Dart</label></div>
|
||||||
<div class="tabbed-content">
|
<div class="tabbed-content">
|
||||||
<div class="tabbed-block">
|
<div class="tabbed-block">
|
||||||
|
@ -3455,21 +3451,15 @@ f(x) = x \bmod {100}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<h2 id="613">6.1.3. 哈希冲突<a class="headerlink" href="#613" title="Permanent link">¶</a></h2>
|
<h2 id="613">6.1.3. 哈希冲突<a class="headerlink" href="#613" title="Permanent link">¶</a></h2>
|
||||||
<p>细心的你可能已经注意到,<strong>在某些情况下,哈希函数 <span class="arithmatex">\(f(x) = x \bmod 100\)</span> 可能无法正常工作</strong>。具体来说,当输入的 key 后两位相同时,哈希函数的计算结果也会相同,从而指向同一个 value 。例如,查询学号为 <span class="arithmatex">\(12836\)</span> 和 <span class="arithmatex">\(20336\)</span> 的两个学生时,我们得到:</p>
|
<p>本质上看,哈希函数的是将一个庞大的输入空间(<code>key</code> 范围)映射到一个较小的输出空间(数组索引范围)。因此,<strong>理论上一定存在”多个输入对应相同输出”的情况</strong>。</p>
|
||||||
|
<p>对于上述示例中的哈希函数,当输入的 <code>key</code> 后两位相同时,哈希函数的输出结果也相同。例如,查询学号为 <span class="arithmatex">\(12836\)</span> 和 <span class="arithmatex">\(20336\)</span> 的两个学生时,我们得到:</p>
|
||||||
<div class="arithmatex">\[
|
<div class="arithmatex">\[
|
||||||
f(12836) = f(20336) = 36
|
12836 \bmod 100 = 20336 \bmod 100 = 36
|
||||||
\]</div>
|
\]</div>
|
||||||
<p>这两个学号指向了同一个姓名,这显然是错误的。我们把这种情况称为「哈希冲突 Hash Collision」。在后续章节中,我们将讨论如何解决哈希冲突的问题。</p>
|
<p>两个学号指向了同一个姓名,这显然是不对的。我们把这种情况称为“哈希冲突”。在下节中,我们将重点讨论如何解决冲突问题。</p>
|
||||||
<p><img alt="哈希冲突示例" src="../hash_map.assets/hash_collision.png" /></p>
|
<p><img alt="哈希冲突示例" src="../hash_map.assets/hash_collision.png" /></p>
|
||||||
<p align="center"> Fig. 哈希冲突示例 </p>
|
<p align="center"> Fig. 哈希冲突示例 </p>
|
||||||
|
|
||||||
<p>综上所述,一个优秀的哈希函数应具备以下特性:</p>
|
|
||||||
<ul>
|
|
||||||
<li>尽可能减少哈希冲突的发生;</li>
|
|
||||||
<li>查询效率高且稳定,能够在绝大多数情况下达到 <span class="arithmatex">\(O(1)\)</span> 时间复杂度;</li>
|
|
||||||
<li>较高的空间利用率,即使“键值对占用空间 / 哈希表总占用空间”比例最大化;</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
152
sitemap.xml
|
@ -2,382 +2,382 @@
|
||||||
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
||||||
<url>
|
<url>
|
||||||
<loc>https://www.hello-algo.com/</loc>
|
<loc>https://www.hello-algo.com/</loc>
|
||||||
<lastmod>2023-06-13</lastmod>
|
<lastmod>2023-06-14</lastmod>
|
||||||
<changefreq>daily</changefreq>
|
<changefreq>daily</changefreq>
|
||||||
</url>
|
</url>
|
||||||
<url>
|
<url>
|
||||||
<loc>https://www.hello-algo.com/chapter_appendix/contribution/</loc>
|
<loc>https://www.hello-algo.com/chapter_appendix/contribution/</loc>
|
||||||
<lastmod>2023-06-13</lastmod>
|
<lastmod>2023-06-14</lastmod>
|
||||||
<changefreq>daily</changefreq>
|
<changefreq>daily</changefreq>
|
||||||
</url>
|
</url>
|
||||||
<url>
|
<url>
|
||||||
<loc>https://www.hello-algo.com/chapter_appendix/installation/</loc>
|
<loc>https://www.hello-algo.com/chapter_appendix/installation/</loc>
|
||||||
<lastmod>2023-06-13</lastmod>
|
<lastmod>2023-06-14</lastmod>
|
||||||
<changefreq>daily</changefreq>
|
<changefreq>daily</changefreq>
|
||||||
</url>
|
</url>
|
||||||
<url>
|
<url>
|
||||||
<loc>https://www.hello-algo.com/chapter_array_and_linkedlist/</loc>
|
<loc>https://www.hello-algo.com/chapter_array_and_linkedlist/</loc>
|
||||||
<lastmod>2023-06-13</lastmod>
|
<lastmod>2023-06-14</lastmod>
|
||||||
<changefreq>daily</changefreq>
|
<changefreq>daily</changefreq>
|
||||||
</url>
|
</url>
|
||||||
<url>
|
<url>
|
||||||
<loc>https://www.hello-algo.com/chapter_array_and_linkedlist/array/</loc>
|
<loc>https://www.hello-algo.com/chapter_array_and_linkedlist/array/</loc>
|
||||||
<lastmod>2023-06-13</lastmod>
|
<lastmod>2023-06-14</lastmod>
|
||||||
<changefreq>daily</changefreq>
|
<changefreq>daily</changefreq>
|
||||||
</url>
|
</url>
|
||||||
<url>
|
<url>
|
||||||
<loc>https://www.hello-algo.com/chapter_array_and_linkedlist/linked_list/</loc>
|
<loc>https://www.hello-algo.com/chapter_array_and_linkedlist/linked_list/</loc>
|
||||||
<lastmod>2023-06-13</lastmod>
|
<lastmod>2023-06-14</lastmod>
|
||||||
<changefreq>daily</changefreq>
|
<changefreq>daily</changefreq>
|
||||||
</url>
|
</url>
|
||||||
<url>
|
<url>
|
||||||
<loc>https://www.hello-algo.com/chapter_array_and_linkedlist/list/</loc>
|
<loc>https://www.hello-algo.com/chapter_array_and_linkedlist/list/</loc>
|
||||||
<lastmod>2023-06-13</lastmod>
|
<lastmod>2023-06-14</lastmod>
|
||||||
<changefreq>daily</changefreq>
|
<changefreq>daily</changefreq>
|
||||||
</url>
|
</url>
|
||||||
<url>
|
<url>
|
||||||
<loc>https://www.hello-algo.com/chapter_array_and_linkedlist/summary/</loc>
|
<loc>https://www.hello-algo.com/chapter_array_and_linkedlist/summary/</loc>
|
||||||
<lastmod>2023-06-13</lastmod>
|
<lastmod>2023-06-14</lastmod>
|
||||||
<changefreq>daily</changefreq>
|
<changefreq>daily</changefreq>
|
||||||
</url>
|
</url>
|
||||||
<url>
|
<url>
|
||||||
<loc>https://www.hello-algo.com/chapter_backtracking/</loc>
|
<loc>https://www.hello-algo.com/chapter_backtracking/</loc>
|
||||||
<lastmod>2023-06-13</lastmod>
|
<lastmod>2023-06-14</lastmod>
|
||||||
<changefreq>daily</changefreq>
|
<changefreq>daily</changefreq>
|
||||||
</url>
|
</url>
|
||||||
<url>
|
<url>
|
||||||
<loc>https://www.hello-algo.com/chapter_backtracking/backtracking_algorithm/</loc>
|
<loc>https://www.hello-algo.com/chapter_backtracking/backtracking_algorithm/</loc>
|
||||||
<lastmod>2023-06-13</lastmod>
|
<lastmod>2023-06-14</lastmod>
|
||||||
<changefreq>daily</changefreq>
|
<changefreq>daily</changefreq>
|
||||||
</url>
|
</url>
|
||||||
<url>
|
<url>
|
||||||
<loc>https://www.hello-algo.com/chapter_backtracking/n_queens_problem/</loc>
|
<loc>https://www.hello-algo.com/chapter_backtracking/n_queens_problem/</loc>
|
||||||
<lastmod>2023-06-13</lastmod>
|
<lastmod>2023-06-14</lastmod>
|
||||||
<changefreq>daily</changefreq>
|
<changefreq>daily</changefreq>
|
||||||
</url>
|
</url>
|
||||||
<url>
|
<url>
|
||||||
<loc>https://www.hello-algo.com/chapter_backtracking/permutations_problem/</loc>
|
<loc>https://www.hello-algo.com/chapter_backtracking/permutations_problem/</loc>
|
||||||
<lastmod>2023-06-13</lastmod>
|
<lastmod>2023-06-14</lastmod>
|
||||||
<changefreq>daily</changefreq>
|
<changefreq>daily</changefreq>
|
||||||
</url>
|
</url>
|
||||||
<url>
|
<url>
|
||||||
<loc>https://www.hello-algo.com/chapter_computational_complexity/</loc>
|
<loc>https://www.hello-algo.com/chapter_computational_complexity/</loc>
|
||||||
<lastmod>2023-06-13</lastmod>
|
<lastmod>2023-06-14</lastmod>
|
||||||
<changefreq>daily</changefreq>
|
<changefreq>daily</changefreq>
|
||||||
</url>
|
</url>
|
||||||
<url>
|
<url>
|
||||||
<loc>https://www.hello-algo.com/chapter_computational_complexity/performance_evaluation/</loc>
|
<loc>https://www.hello-algo.com/chapter_computational_complexity/performance_evaluation/</loc>
|
||||||
<lastmod>2023-06-13</lastmod>
|
<lastmod>2023-06-14</lastmod>
|
||||||
<changefreq>daily</changefreq>
|
<changefreq>daily</changefreq>
|
||||||
</url>
|
</url>
|
||||||
<url>
|
<url>
|
||||||
<loc>https://www.hello-algo.com/chapter_computational_complexity/space_complexity/</loc>
|
<loc>https://www.hello-algo.com/chapter_computational_complexity/space_complexity/</loc>
|
||||||
<lastmod>2023-06-13</lastmod>
|
<lastmod>2023-06-14</lastmod>
|
||||||
<changefreq>daily</changefreq>
|
<changefreq>daily</changefreq>
|
||||||
</url>
|
</url>
|
||||||
<url>
|
<url>
|
||||||
<loc>https://www.hello-algo.com/chapter_computational_complexity/summary/</loc>
|
<loc>https://www.hello-algo.com/chapter_computational_complexity/summary/</loc>
|
||||||
<lastmod>2023-06-13</lastmod>
|
<lastmod>2023-06-14</lastmod>
|
||||||
<changefreq>daily</changefreq>
|
<changefreq>daily</changefreq>
|
||||||
</url>
|
</url>
|
||||||
<url>
|
<url>
|
||||||
<loc>https://www.hello-algo.com/chapter_computational_complexity/time_complexity/</loc>
|
<loc>https://www.hello-algo.com/chapter_computational_complexity/time_complexity/</loc>
|
||||||
<lastmod>2023-06-13</lastmod>
|
<lastmod>2023-06-14</lastmod>
|
||||||
<changefreq>daily</changefreq>
|
<changefreq>daily</changefreq>
|
||||||
</url>
|
</url>
|
||||||
<url>
|
<url>
|
||||||
<loc>https://www.hello-algo.com/chapter_data_structure/</loc>
|
<loc>https://www.hello-algo.com/chapter_data_structure/</loc>
|
||||||
<lastmod>2023-06-13</lastmod>
|
<lastmod>2023-06-14</lastmod>
|
||||||
<changefreq>daily</changefreq>
|
<changefreq>daily</changefreq>
|
||||||
</url>
|
</url>
|
||||||
<url>
|
<url>
|
||||||
<loc>https://www.hello-algo.com/chapter_data_structure/basic_data_types/</loc>
|
<loc>https://www.hello-algo.com/chapter_data_structure/basic_data_types/</loc>
|
||||||
<lastmod>2023-06-13</lastmod>
|
<lastmod>2023-06-14</lastmod>
|
||||||
<changefreq>daily</changefreq>
|
<changefreq>daily</changefreq>
|
||||||
</url>
|
</url>
|
||||||
<url>
|
<url>
|
||||||
<loc>https://www.hello-algo.com/chapter_data_structure/character_encoding/</loc>
|
<loc>https://www.hello-algo.com/chapter_data_structure/character_encoding/</loc>
|
||||||
<lastmod>2023-06-13</lastmod>
|
<lastmod>2023-06-14</lastmod>
|
||||||
<changefreq>daily</changefreq>
|
<changefreq>daily</changefreq>
|
||||||
</url>
|
</url>
|
||||||
<url>
|
<url>
|
||||||
<loc>https://www.hello-algo.com/chapter_data_structure/classification_of_data_structure/</loc>
|
<loc>https://www.hello-algo.com/chapter_data_structure/classification_of_data_structure/</loc>
|
||||||
<lastmod>2023-06-13</lastmod>
|
<lastmod>2023-06-14</lastmod>
|
||||||
<changefreq>daily</changefreq>
|
<changefreq>daily</changefreq>
|
||||||
</url>
|
</url>
|
||||||
<url>
|
<url>
|
||||||
<loc>https://www.hello-algo.com/chapter_data_structure/number_encoding/</loc>
|
<loc>https://www.hello-algo.com/chapter_data_structure/number_encoding/</loc>
|
||||||
<lastmod>2023-06-13</lastmod>
|
<lastmod>2023-06-14</lastmod>
|
||||||
<changefreq>daily</changefreq>
|
<changefreq>daily</changefreq>
|
||||||
</url>
|
</url>
|
||||||
<url>
|
<url>
|
||||||
<loc>https://www.hello-algo.com/chapter_data_structure/summary/</loc>
|
<loc>https://www.hello-algo.com/chapter_data_structure/summary/</loc>
|
||||||
<lastmod>2023-06-13</lastmod>
|
<lastmod>2023-06-14</lastmod>
|
||||||
<changefreq>daily</changefreq>
|
<changefreq>daily</changefreq>
|
||||||
</url>
|
</url>
|
||||||
<url>
|
<url>
|
||||||
<loc>https://www.hello-algo.com/chapter_graph/</loc>
|
<loc>https://www.hello-algo.com/chapter_graph/</loc>
|
||||||
<lastmod>2023-06-13</lastmod>
|
<lastmod>2023-06-14</lastmod>
|
||||||
<changefreq>daily</changefreq>
|
<changefreq>daily</changefreq>
|
||||||
</url>
|
</url>
|
||||||
<url>
|
<url>
|
||||||
<loc>https://www.hello-algo.com/chapter_graph/graph/</loc>
|
<loc>https://www.hello-algo.com/chapter_graph/graph/</loc>
|
||||||
<lastmod>2023-06-13</lastmod>
|
<lastmod>2023-06-14</lastmod>
|
||||||
<changefreq>daily</changefreq>
|
<changefreq>daily</changefreq>
|
||||||
</url>
|
</url>
|
||||||
<url>
|
<url>
|
||||||
<loc>https://www.hello-algo.com/chapter_graph/graph_operations/</loc>
|
<loc>https://www.hello-algo.com/chapter_graph/graph_operations/</loc>
|
||||||
<lastmod>2023-06-13</lastmod>
|
<lastmod>2023-06-14</lastmod>
|
||||||
<changefreq>daily</changefreq>
|
<changefreq>daily</changefreq>
|
||||||
</url>
|
</url>
|
||||||
<url>
|
<url>
|
||||||
<loc>https://www.hello-algo.com/chapter_graph/graph_traversal/</loc>
|
<loc>https://www.hello-algo.com/chapter_graph/graph_traversal/</loc>
|
||||||
<lastmod>2023-06-13</lastmod>
|
<lastmod>2023-06-14</lastmod>
|
||||||
<changefreq>daily</changefreq>
|
<changefreq>daily</changefreq>
|
||||||
</url>
|
</url>
|
||||||
<url>
|
<url>
|
||||||
<loc>https://www.hello-algo.com/chapter_graph/summary/</loc>
|
<loc>https://www.hello-algo.com/chapter_graph/summary/</loc>
|
||||||
<lastmod>2023-06-13</lastmod>
|
<lastmod>2023-06-14</lastmod>
|
||||||
<changefreq>daily</changefreq>
|
<changefreq>daily</changefreq>
|
||||||
</url>
|
</url>
|
||||||
<url>
|
<url>
|
||||||
<loc>https://www.hello-algo.com/chapter_hashing/</loc>
|
<loc>https://www.hello-algo.com/chapter_hashing/</loc>
|
||||||
<lastmod>2023-06-13</lastmod>
|
<lastmod>2023-06-14</lastmod>
|
||||||
<changefreq>daily</changefreq>
|
<changefreq>daily</changefreq>
|
||||||
</url>
|
</url>
|
||||||
<url>
|
<url>
|
||||||
<loc>https://www.hello-algo.com/chapter_hashing/hash_collision/</loc>
|
<loc>https://www.hello-algo.com/chapter_hashing/hash_collision/</loc>
|
||||||
<lastmod>2023-06-13</lastmod>
|
<lastmod>2023-06-14</lastmod>
|
||||||
<changefreq>daily</changefreq>
|
<changefreq>daily</changefreq>
|
||||||
</url>
|
</url>
|
||||||
<url>
|
<url>
|
||||||
<loc>https://www.hello-algo.com/chapter_hashing/hash_map/</loc>
|
<loc>https://www.hello-algo.com/chapter_hashing/hash_map/</loc>
|
||||||
<lastmod>2023-06-13</lastmod>
|
<lastmod>2023-06-14</lastmod>
|
||||||
<changefreq>daily</changefreq>
|
<changefreq>daily</changefreq>
|
||||||
</url>
|
</url>
|
||||||
<url>
|
<url>
|
||||||
<loc>https://www.hello-algo.com/chapter_hashing/summary/</loc>
|
<loc>https://www.hello-algo.com/chapter_hashing/summary/</loc>
|
||||||
<lastmod>2023-06-13</lastmod>
|
<lastmod>2023-06-14</lastmod>
|
||||||
<changefreq>daily</changefreq>
|
<changefreq>daily</changefreq>
|
||||||
</url>
|
</url>
|
||||||
<url>
|
<url>
|
||||||
<loc>https://www.hello-algo.com/chapter_heap/</loc>
|
<loc>https://www.hello-algo.com/chapter_heap/</loc>
|
||||||
<lastmod>2023-06-13</lastmod>
|
<lastmod>2023-06-14</lastmod>
|
||||||
<changefreq>daily</changefreq>
|
<changefreq>daily</changefreq>
|
||||||
</url>
|
</url>
|
||||||
<url>
|
<url>
|
||||||
<loc>https://www.hello-algo.com/chapter_heap/build_heap/</loc>
|
<loc>https://www.hello-algo.com/chapter_heap/build_heap/</loc>
|
||||||
<lastmod>2023-06-13</lastmod>
|
<lastmod>2023-06-14</lastmod>
|
||||||
<changefreq>daily</changefreq>
|
<changefreq>daily</changefreq>
|
||||||
</url>
|
</url>
|
||||||
<url>
|
<url>
|
||||||
<loc>https://www.hello-algo.com/chapter_heap/heap/</loc>
|
<loc>https://www.hello-algo.com/chapter_heap/heap/</loc>
|
||||||
<lastmod>2023-06-13</lastmod>
|
<lastmod>2023-06-14</lastmod>
|
||||||
<changefreq>daily</changefreq>
|
<changefreq>daily</changefreq>
|
||||||
</url>
|
</url>
|
||||||
<url>
|
<url>
|
||||||
<loc>https://www.hello-algo.com/chapter_heap/summary/</loc>
|
<loc>https://www.hello-algo.com/chapter_heap/summary/</loc>
|
||||||
<lastmod>2023-06-13</lastmod>
|
<lastmod>2023-06-14</lastmod>
|
||||||
<changefreq>daily</changefreq>
|
<changefreq>daily</changefreq>
|
||||||
</url>
|
</url>
|
||||||
<url>
|
<url>
|
||||||
<loc>https://www.hello-algo.com/chapter_heap/top_k/</loc>
|
<loc>https://www.hello-algo.com/chapter_heap/top_k/</loc>
|
||||||
<lastmod>2023-06-13</lastmod>
|
<lastmod>2023-06-14</lastmod>
|
||||||
<changefreq>daily</changefreq>
|
<changefreq>daily</changefreq>
|
||||||
</url>
|
</url>
|
||||||
<url>
|
<url>
|
||||||
<loc>https://www.hello-algo.com/chapter_introduction/</loc>
|
<loc>https://www.hello-algo.com/chapter_introduction/</loc>
|
||||||
<lastmod>2023-06-13</lastmod>
|
<lastmod>2023-06-14</lastmod>
|
||||||
<changefreq>daily</changefreq>
|
<changefreq>daily</changefreq>
|
||||||
</url>
|
</url>
|
||||||
<url>
|
<url>
|
||||||
<loc>https://www.hello-algo.com/chapter_introduction/algorithms_are_everywhere/</loc>
|
<loc>https://www.hello-algo.com/chapter_introduction/algorithms_are_everywhere/</loc>
|
||||||
<lastmod>2023-06-13</lastmod>
|
<lastmod>2023-06-14</lastmod>
|
||||||
<changefreq>daily</changefreq>
|
<changefreq>daily</changefreq>
|
||||||
</url>
|
</url>
|
||||||
<url>
|
<url>
|
||||||
<loc>https://www.hello-algo.com/chapter_introduction/summary/</loc>
|
<loc>https://www.hello-algo.com/chapter_introduction/summary/</loc>
|
||||||
<lastmod>2023-06-13</lastmod>
|
<lastmod>2023-06-14</lastmod>
|
||||||
<changefreq>daily</changefreq>
|
<changefreq>daily</changefreq>
|
||||||
</url>
|
</url>
|
||||||
<url>
|
<url>
|
||||||
<loc>https://www.hello-algo.com/chapter_introduction/what_is_dsa/</loc>
|
<loc>https://www.hello-algo.com/chapter_introduction/what_is_dsa/</loc>
|
||||||
<lastmod>2023-06-13</lastmod>
|
<lastmod>2023-06-14</lastmod>
|
||||||
<changefreq>daily</changefreq>
|
<changefreq>daily</changefreq>
|
||||||
</url>
|
</url>
|
||||||
<url>
|
<url>
|
||||||
<loc>https://www.hello-algo.com/chapter_preface/</loc>
|
<loc>https://www.hello-algo.com/chapter_preface/</loc>
|
||||||
<lastmod>2023-06-13</lastmod>
|
<lastmod>2023-06-14</lastmod>
|
||||||
<changefreq>daily</changefreq>
|
<changefreq>daily</changefreq>
|
||||||
</url>
|
</url>
|
||||||
<url>
|
<url>
|
||||||
<loc>https://www.hello-algo.com/chapter_preface/about_the_book/</loc>
|
<loc>https://www.hello-algo.com/chapter_preface/about_the_book/</loc>
|
||||||
<lastmod>2023-06-13</lastmod>
|
<lastmod>2023-06-14</lastmod>
|
||||||
<changefreq>daily</changefreq>
|
<changefreq>daily</changefreq>
|
||||||
</url>
|
</url>
|
||||||
<url>
|
<url>
|
||||||
<loc>https://www.hello-algo.com/chapter_preface/suggestions/</loc>
|
<loc>https://www.hello-algo.com/chapter_preface/suggestions/</loc>
|
||||||
<lastmod>2023-06-13</lastmod>
|
<lastmod>2023-06-14</lastmod>
|
||||||
<changefreq>daily</changefreq>
|
<changefreq>daily</changefreq>
|
||||||
</url>
|
</url>
|
||||||
<url>
|
<url>
|
||||||
<loc>https://www.hello-algo.com/chapter_preface/summary/</loc>
|
<loc>https://www.hello-algo.com/chapter_preface/summary/</loc>
|
||||||
<lastmod>2023-06-13</lastmod>
|
<lastmod>2023-06-14</lastmod>
|
||||||
<changefreq>daily</changefreq>
|
<changefreq>daily</changefreq>
|
||||||
</url>
|
</url>
|
||||||
<url>
|
<url>
|
||||||
<loc>https://www.hello-algo.com/chapter_reference/</loc>
|
<loc>https://www.hello-algo.com/chapter_reference/</loc>
|
||||||
<lastmod>2023-06-13</lastmod>
|
<lastmod>2023-06-14</lastmod>
|
||||||
<changefreq>daily</changefreq>
|
<changefreq>daily</changefreq>
|
||||||
</url>
|
</url>
|
||||||
<url>
|
<url>
|
||||||
<loc>https://www.hello-algo.com/chapter_searching/</loc>
|
<loc>https://www.hello-algo.com/chapter_searching/</loc>
|
||||||
<lastmod>2023-06-13</lastmod>
|
<lastmod>2023-06-14</lastmod>
|
||||||
<changefreq>daily</changefreq>
|
<changefreq>daily</changefreq>
|
||||||
</url>
|
</url>
|
||||||
<url>
|
<url>
|
||||||
<loc>https://www.hello-algo.com/chapter_searching/binary_search/</loc>
|
<loc>https://www.hello-algo.com/chapter_searching/binary_search/</loc>
|
||||||
<lastmod>2023-06-13</lastmod>
|
<lastmod>2023-06-14</lastmod>
|
||||||
<changefreq>daily</changefreq>
|
<changefreq>daily</changefreq>
|
||||||
</url>
|
</url>
|
||||||
<url>
|
<url>
|
||||||
<loc>https://www.hello-algo.com/chapter_searching/binary_search_edge/</loc>
|
<loc>https://www.hello-algo.com/chapter_searching/binary_search_edge/</loc>
|
||||||
<lastmod>2023-06-13</lastmod>
|
<lastmod>2023-06-14</lastmod>
|
||||||
<changefreq>daily</changefreq>
|
<changefreq>daily</changefreq>
|
||||||
</url>
|
</url>
|
||||||
<url>
|
<url>
|
||||||
<loc>https://www.hello-algo.com/chapter_searching/replace_linear_by_hashing/</loc>
|
<loc>https://www.hello-algo.com/chapter_searching/replace_linear_by_hashing/</loc>
|
||||||
<lastmod>2023-06-13</lastmod>
|
<lastmod>2023-06-14</lastmod>
|
||||||
<changefreq>daily</changefreq>
|
<changefreq>daily</changefreq>
|
||||||
</url>
|
</url>
|
||||||
<url>
|
<url>
|
||||||
<loc>https://www.hello-algo.com/chapter_searching/searching_algorithm_revisited/</loc>
|
<loc>https://www.hello-algo.com/chapter_searching/searching_algorithm_revisited/</loc>
|
||||||
<lastmod>2023-06-13</lastmod>
|
<lastmod>2023-06-14</lastmod>
|
||||||
<changefreq>daily</changefreq>
|
<changefreq>daily</changefreq>
|
||||||
</url>
|
</url>
|
||||||
<url>
|
<url>
|
||||||
<loc>https://www.hello-algo.com/chapter_searching/summary/</loc>
|
<loc>https://www.hello-algo.com/chapter_searching/summary/</loc>
|
||||||
<lastmod>2023-06-13</lastmod>
|
<lastmod>2023-06-14</lastmod>
|
||||||
<changefreq>daily</changefreq>
|
<changefreq>daily</changefreq>
|
||||||
</url>
|
</url>
|
||||||
<url>
|
<url>
|
||||||
<loc>https://www.hello-algo.com/chapter_sorting/</loc>
|
<loc>https://www.hello-algo.com/chapter_sorting/</loc>
|
||||||
<lastmod>2023-06-13</lastmod>
|
<lastmod>2023-06-14</lastmod>
|
||||||
<changefreq>daily</changefreq>
|
<changefreq>daily</changefreq>
|
||||||
</url>
|
</url>
|
||||||
<url>
|
<url>
|
||||||
<loc>https://www.hello-algo.com/chapter_sorting/bubble_sort/</loc>
|
<loc>https://www.hello-algo.com/chapter_sorting/bubble_sort/</loc>
|
||||||
<lastmod>2023-06-13</lastmod>
|
<lastmod>2023-06-14</lastmod>
|
||||||
<changefreq>daily</changefreq>
|
<changefreq>daily</changefreq>
|
||||||
</url>
|
</url>
|
||||||
<url>
|
<url>
|
||||||
<loc>https://www.hello-algo.com/chapter_sorting/bucket_sort/</loc>
|
<loc>https://www.hello-algo.com/chapter_sorting/bucket_sort/</loc>
|
||||||
<lastmod>2023-06-13</lastmod>
|
<lastmod>2023-06-14</lastmod>
|
||||||
<changefreq>daily</changefreq>
|
<changefreq>daily</changefreq>
|
||||||
</url>
|
</url>
|
||||||
<url>
|
<url>
|
||||||
<loc>https://www.hello-algo.com/chapter_sorting/counting_sort/</loc>
|
<loc>https://www.hello-algo.com/chapter_sorting/counting_sort/</loc>
|
||||||
<lastmod>2023-06-13</lastmod>
|
<lastmod>2023-06-14</lastmod>
|
||||||
<changefreq>daily</changefreq>
|
<changefreq>daily</changefreq>
|
||||||
</url>
|
</url>
|
||||||
<url>
|
<url>
|
||||||
<loc>https://www.hello-algo.com/chapter_sorting/heap_sort/</loc>
|
<loc>https://www.hello-algo.com/chapter_sorting/heap_sort/</loc>
|
||||||
<lastmod>2023-06-13</lastmod>
|
<lastmod>2023-06-14</lastmod>
|
||||||
<changefreq>daily</changefreq>
|
<changefreq>daily</changefreq>
|
||||||
</url>
|
</url>
|
||||||
<url>
|
<url>
|
||||||
<loc>https://www.hello-algo.com/chapter_sorting/insertion_sort/</loc>
|
<loc>https://www.hello-algo.com/chapter_sorting/insertion_sort/</loc>
|
||||||
<lastmod>2023-06-13</lastmod>
|
<lastmod>2023-06-14</lastmod>
|
||||||
<changefreq>daily</changefreq>
|
<changefreq>daily</changefreq>
|
||||||
</url>
|
</url>
|
||||||
<url>
|
<url>
|
||||||
<loc>https://www.hello-algo.com/chapter_sorting/merge_sort/</loc>
|
<loc>https://www.hello-algo.com/chapter_sorting/merge_sort/</loc>
|
||||||
<lastmod>2023-06-13</lastmod>
|
<lastmod>2023-06-14</lastmod>
|
||||||
<changefreq>daily</changefreq>
|
<changefreq>daily</changefreq>
|
||||||
</url>
|
</url>
|
||||||
<url>
|
<url>
|
||||||
<loc>https://www.hello-algo.com/chapter_sorting/quick_sort/</loc>
|
<loc>https://www.hello-algo.com/chapter_sorting/quick_sort/</loc>
|
||||||
<lastmod>2023-06-13</lastmod>
|
<lastmod>2023-06-14</lastmod>
|
||||||
<changefreq>daily</changefreq>
|
<changefreq>daily</changefreq>
|
||||||
</url>
|
</url>
|
||||||
<url>
|
<url>
|
||||||
<loc>https://www.hello-algo.com/chapter_sorting/radix_sort/</loc>
|
<loc>https://www.hello-algo.com/chapter_sorting/radix_sort/</loc>
|
||||||
<lastmod>2023-06-13</lastmod>
|
<lastmod>2023-06-14</lastmod>
|
||||||
<changefreq>daily</changefreq>
|
<changefreq>daily</changefreq>
|
||||||
</url>
|
</url>
|
||||||
<url>
|
<url>
|
||||||
<loc>https://www.hello-algo.com/chapter_sorting/selection_sort/</loc>
|
<loc>https://www.hello-algo.com/chapter_sorting/selection_sort/</loc>
|
||||||
<lastmod>2023-06-13</lastmod>
|
<lastmod>2023-06-14</lastmod>
|
||||||
<changefreq>daily</changefreq>
|
<changefreq>daily</changefreq>
|
||||||
</url>
|
</url>
|
||||||
<url>
|
<url>
|
||||||
<loc>https://www.hello-algo.com/chapter_sorting/sorting_algorithm/</loc>
|
<loc>https://www.hello-algo.com/chapter_sorting/sorting_algorithm/</loc>
|
||||||
<lastmod>2023-06-13</lastmod>
|
<lastmod>2023-06-14</lastmod>
|
||||||
<changefreq>daily</changefreq>
|
<changefreq>daily</changefreq>
|
||||||
</url>
|
</url>
|
||||||
<url>
|
<url>
|
||||||
<loc>https://www.hello-algo.com/chapter_sorting/summary/</loc>
|
<loc>https://www.hello-algo.com/chapter_sorting/summary/</loc>
|
||||||
<lastmod>2023-06-13</lastmod>
|
<lastmod>2023-06-14</lastmod>
|
||||||
<changefreq>daily</changefreq>
|
<changefreq>daily</changefreq>
|
||||||
</url>
|
</url>
|
||||||
<url>
|
<url>
|
||||||
<loc>https://www.hello-algo.com/chapter_stack_and_queue/</loc>
|
<loc>https://www.hello-algo.com/chapter_stack_and_queue/</loc>
|
||||||
<lastmod>2023-06-13</lastmod>
|
<lastmod>2023-06-14</lastmod>
|
||||||
<changefreq>daily</changefreq>
|
<changefreq>daily</changefreq>
|
||||||
</url>
|
</url>
|
||||||
<url>
|
<url>
|
||||||
<loc>https://www.hello-algo.com/chapter_stack_and_queue/deque/</loc>
|
<loc>https://www.hello-algo.com/chapter_stack_and_queue/deque/</loc>
|
||||||
<lastmod>2023-06-13</lastmod>
|
<lastmod>2023-06-14</lastmod>
|
||||||
<changefreq>daily</changefreq>
|
<changefreq>daily</changefreq>
|
||||||
</url>
|
</url>
|
||||||
<url>
|
<url>
|
||||||
<loc>https://www.hello-algo.com/chapter_stack_and_queue/queue/</loc>
|
<loc>https://www.hello-algo.com/chapter_stack_and_queue/queue/</loc>
|
||||||
<lastmod>2023-06-13</lastmod>
|
<lastmod>2023-06-14</lastmod>
|
||||||
<changefreq>daily</changefreq>
|
<changefreq>daily</changefreq>
|
||||||
</url>
|
</url>
|
||||||
<url>
|
<url>
|
||||||
<loc>https://www.hello-algo.com/chapter_stack_and_queue/stack/</loc>
|
<loc>https://www.hello-algo.com/chapter_stack_and_queue/stack/</loc>
|
||||||
<lastmod>2023-06-13</lastmod>
|
<lastmod>2023-06-14</lastmod>
|
||||||
<changefreq>daily</changefreq>
|
<changefreq>daily</changefreq>
|
||||||
</url>
|
</url>
|
||||||
<url>
|
<url>
|
||||||
<loc>https://www.hello-algo.com/chapter_stack_and_queue/summary/</loc>
|
<loc>https://www.hello-algo.com/chapter_stack_and_queue/summary/</loc>
|
||||||
<lastmod>2023-06-13</lastmod>
|
<lastmod>2023-06-14</lastmod>
|
||||||
<changefreq>daily</changefreq>
|
<changefreq>daily</changefreq>
|
||||||
</url>
|
</url>
|
||||||
<url>
|
<url>
|
||||||
<loc>https://www.hello-algo.com/chapter_tree/</loc>
|
<loc>https://www.hello-algo.com/chapter_tree/</loc>
|
||||||
<lastmod>2023-06-13</lastmod>
|
<lastmod>2023-06-14</lastmod>
|
||||||
<changefreq>daily</changefreq>
|
<changefreq>daily</changefreq>
|
||||||
</url>
|
</url>
|
||||||
<url>
|
<url>
|
||||||
<loc>https://www.hello-algo.com/chapter_tree/array_representation_of_tree/</loc>
|
<loc>https://www.hello-algo.com/chapter_tree/array_representation_of_tree/</loc>
|
||||||
<lastmod>2023-06-13</lastmod>
|
<lastmod>2023-06-14</lastmod>
|
||||||
<changefreq>daily</changefreq>
|
<changefreq>daily</changefreq>
|
||||||
</url>
|
</url>
|
||||||
<url>
|
<url>
|
||||||
<loc>https://www.hello-algo.com/chapter_tree/avl_tree/</loc>
|
<loc>https://www.hello-algo.com/chapter_tree/avl_tree/</loc>
|
||||||
<lastmod>2023-06-13</lastmod>
|
<lastmod>2023-06-14</lastmod>
|
||||||
<changefreq>daily</changefreq>
|
<changefreq>daily</changefreq>
|
||||||
</url>
|
</url>
|
||||||
<url>
|
<url>
|
||||||
<loc>https://www.hello-algo.com/chapter_tree/binary_search_tree/</loc>
|
<loc>https://www.hello-algo.com/chapter_tree/binary_search_tree/</loc>
|
||||||
<lastmod>2023-06-13</lastmod>
|
<lastmod>2023-06-14</lastmod>
|
||||||
<changefreq>daily</changefreq>
|
<changefreq>daily</changefreq>
|
||||||
</url>
|
</url>
|
||||||
<url>
|
<url>
|
||||||
<loc>https://www.hello-algo.com/chapter_tree/binary_tree/</loc>
|
<loc>https://www.hello-algo.com/chapter_tree/binary_tree/</loc>
|
||||||
<lastmod>2023-06-13</lastmod>
|
<lastmod>2023-06-14</lastmod>
|
||||||
<changefreq>daily</changefreq>
|
<changefreq>daily</changefreq>
|
||||||
</url>
|
</url>
|
||||||
<url>
|
<url>
|
||||||
<loc>https://www.hello-algo.com/chapter_tree/binary_tree_traversal/</loc>
|
<loc>https://www.hello-algo.com/chapter_tree/binary_tree_traversal/</loc>
|
||||||
<lastmod>2023-06-13</lastmod>
|
<lastmod>2023-06-14</lastmod>
|
||||||
<changefreq>daily</changefreq>
|
<changefreq>daily</changefreq>
|
||||||
</url>
|
</url>
|
||||||
<url>
|
<url>
|
||||||
<loc>https://www.hello-algo.com/chapter_tree/summary/</loc>
|
<loc>https://www.hello-algo.com/chapter_tree/summary/</loc>
|
||||||
<lastmod>2023-06-13</lastmod>
|
<lastmod>2023-06-14</lastmod>
|
||||||
<changefreq>daily</changefreq>
|
<changefreq>daily</changefreq>
|
||||||
</url>
|
</url>
|
||||||
</urlset>
|
</urlset>
|