Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 8487306

Browse files
committed
Update 01.Hash-Table.md
1 parent 81544f4 commit 8487306

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

‎Contents/05.Hash-Table/01.Hash-Table.md‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
哈希表的原理示例图如下所示:
1313

14-
![](https://qcdn.itcharge.cn/images/20220114120000.png)
14+
![哈希表](https://qcdn.itcharge.cn/images/202405092317578.png)
1515

1616
在上图例子中,我们使用 $value = Hash(key) = key // 1000$ 作为哈希函数。$//$ 符号代表整除。我们以这个例子来说明一下哈希表的插入和查找策略。
1717

@@ -25,7 +25,7 @@
2525

2626
比如为了查找 **「赞」** 这个字的具体意思,我们在字典中根据这个字的拼音索引 `zan`,查找到对应的页码为 599ドル$。然后我们就可以翻到字典的第 599ドル$ 页查看 **「赞」** 字相关的解释了。
2727

28-
![](https://qcdn.itcharge.cn/images/20220111174223.png)
28+
![查字典](https://qcdn.itcharge.cn/images/20220111174223.png)
2929

3030
在这个例子中:
3131

@@ -120,7 +120,7 @@ 343246ドル_{13} = 3 \times 13^5 + 4 \times 13^4 + 3 \times 13^3 + 2 \times 13^2 + 4
120120

121121
使用这三种方法处理冲突的结果如下图所示:
122122

123-
![](https://qcdn.itcharge.cn/images/20220115162728.png)
123+
![开放地址法](https://qcdn.itcharge.cn/images/202405092318809.png)
124124

125125
### 3.2 链地址法
126126

@@ -136,7 +136,7 @@ 343246ドル_{13} = 3 \times 13^5 + 4 \times 13^4 + 3 \times 13^3 + 2 \times 13^2 + 4
136136

137137
举个例子来说明如何使用链地址法处理冲突。假设现在要存入的关键字集合 $keys = [88, 60, 65, 69, 90, 39, 07, 06, 14, 44, 52, 70, 21, 45, 19, 32]$。再假定哈希函数为 $Hash(key) = key \mod 13,ドル哈希表的表长 $m = 13,ドル哈希地址范围为 $[0, m - 1]$。将这些关键字使用链地址法处理冲突,并按顺序加入哈希表中(图示为插入链表表尾位置),最终得到的哈希表如下图所示。
138138

139-
![](https://qcdn.itcharge.cn/images/20220115182535.png)
139+
![链地址法](https://qcdn.itcharge.cn/images/202405092319327.png)
140140

141141
相对于开放地址法,采用链地址法处理冲突要多占用一些存储空间(主要是链节点占用空间)。但它可以减少在进行插入和查找具有相同哈希地址的关键字的操作过程中的平均查找长度。这是因为在链地址法中,待比较的关键字都是具有相同哈希地址的元素,而在开放地址法中,待比较的关键字不仅包含具有相同哈希地址的元素,而且还包含哈希地址不相同的元素。
142142

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /