Double hashing
From Wikipedia, the free encyclopedia
Double hashing is a computer programming technique used in hash tables to resolve hash collisions, cases when two different values to be searched for produce the same hash key. It is a popular collision-resolution technique in open-addressed hash tables.
Like linear probing, it uses one hash value as a starting point and then repeatedly steps forward an interval until the desired value is located, an empty location is reached, or the entire table has been searched; but this interval is decided using a second, independent hash function (hence the name double hashing). Unlike linear probing and quadratic probing, the interval depends on the data, so that even values mapping to the same location have different bucket sequences; this minimizes repeated collisions and the effects of clustering. In other words, given independent hash functions h1 and h2, the jth location in the bucket sequence for value k in a hash table of size m is:

[edit] Disadvantages
Linear probing and, to a lesser extent, quadratic probing are able to take advantage of the data cache by accessing locations that are close together. Double hashing has larger intervals and is not able to achieve this advantage.
Deletions are also complex in a double-hashed hash table. After a collision has occurred for a certain slot, its contents cannot be deleted or all sequences crossing that slot may be severed. Instead, a delete marker known as a tombstone will be put in its place, filling up a slot and slightly degrading search performance. While tombstones can be reused on a later insertion, it is prudent to rebuild the table if the number of tombstones becomes too large.
Like all other forms of open addressing, double hashing becomes linear as the hash table approaches maximum capacity. The only solution to this is to rehash to a larger size.
[edit] See also
[edit] External links
- How Caching Affects Hashing by Gregory L. Heileman and Wenbin Luo 2005.

双重散列是一种解决哈希表中哈希冲突的技术,它使用两个独立的哈希函数,当发生冲突时,通过第二个哈希函数确定步长来寻找下一个位置。这种方法避免了线性探测和二次探测的连续冲突问题,但可能牺牲了缓存效率。在删除元素时,会用特殊标记(墓碑)代替,过多的墓碑可能导致表重建。
924

被折叠的 条评论
为什么被折叠?



