This commit is contained in:
krahets
2023-08-21 03:56:41 +08:00
parent 4d55cafd13
commit 02ac0aa9fe
22 changed files with 87 additions and 83 deletions
+4 -4
View File
@@ -501,8 +501,8 @@ index = hash(key) % capacity
$$
\begin{aligned}
\text{modulus} & = 9 \newline
\text{key} & = \{ 0, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, \cdots \} \newline
\text{hash} & = \{ 0, 3, 6, 0, 3, 6, 0, 3, 6, 0, 3, 6,\cdots \}
\text{key} & = \{ 0, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, \dots \} \newline
\text{hash} & = \{ 0, 3, 6, 0, 3, 6, 0, 3, 6, 0, 3, 6,\dots \}
\end{aligned}
$$
@@ -511,8 +511,8 @@ $$
$$
\begin{aligned}
\text{modulus} & = 13 \newline
\text{key} & = \{ 0, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, \cdots \} \newline
\text{hash} & = \{ 0, 3, 6, 9, 12, 2, 5, 8, 11, 1, 4, 7, \cdots \}
\text{key} & = \{ 0, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, \dots \} \newline
\text{hash} & = \{ 0, 3, 6, 9, 12, 2, 5, 8, 11, 1, 4, 7, \dots \}
\end{aligned}
$$
+1 -1
View File
@@ -2441,7 +2441,7 @@ comments: true
### 2.   多次哈希
顾名思义,多次哈希方法是使用多个哈希函数 $f_1(x)$ , $f_2(x)$ , $f_3(x)$ , $\cdots$ 进行探测。
顾名思义,多次哈希方法是使用多个哈希函数 $f_1(x)$ , $f_2(x)$ , $f_3(x)$ , $\dots$ 进行探测。
- **插入元素**:若哈希函数 $f_1(x)$ 出现冲突,则尝试 $f_2(x)$ ,以此类推,直到找到空位后插入元素。
- **查找元素**:在相同的哈希函数顺序下进行查找,直到找到目标元素时返回;或遇到空位或已尝试所有哈希函数,说明哈希表中不存在该元素,则返回 $\text{None}$ 。
+3 -3
View File
@@ -3,17 +3,17 @@ comments: true
icon: material/table-search
---
# 第 6 章   散列
# 第 6 章   哈希
<div class="center-table" markdown>
![散列](../assets/covers/chapter_hashing.jpg){ width="600" }
![哈希](../assets/covers/chapter_hashing.jpg){ width="600" }
</div>
!!! abstract
在计算机世界中,散列表如同一位智能的图书管理员。
在计算机世界中,哈希表如同一位智能的图书管理员。
他知道如何计算索书号,从而可以快速找到目标书籍。