Hash Table
相关术语:
A hash table uses a hash function to compute an index into an array of buckets or slots, from which the desired value can be found
1. Separate chaining
1.1 Separate chaining with linked lists

bucket
只存储后面list
的头节点
1.2 Separate chaining with list head cells

bucket
存储第一个元素,其余的元素再存在后面的list
中
2. Open addressing

数据都存在bucket
中,没有后面的链表结构, 根据hash
找到的并不是最终的数据,所以称为open
其中对于具有相同hash值的数据,寻找下一个存放地址的方法可以分为3中:
-
Linear probing: 搜寻地址之间等间隔递增 (上图表示的是间隔为1时的情况), 类似
-
Quadratic probing: 搜寻地址之间的间隔为二次多项式的值+由原hash函数计算出的初始值, 类似
- Double hashing: 搜寻地址之间的间隔由另一个hash函数计算而出
ref:
网友评论