本文介绍了我应该在什么时候做的老调重弹整个哈希表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何决定什么时候应该怎么做换汤不换药整个哈希表?

解决方案

这取决于你如何解决冲突很大。如果用户线性探测,性能通常开始严重下降pretty的带负荷率达到60%左右的高得多。如果使用双散列,80-85%的负载系数通常是pretty的合理性。如果您使用的碰撞链接,性能通常保持合理的负载系数高达约150%或以上。

我有时甚至创建了平衡树的冲突解决一个哈希表。在这种情况下,可以几乎的忘记重新散列 - 的性能不会开始恶化明显,直到项目的数量由至少几个数量级超过该表的大小

How do I decide when should I do rehashing of entire hash table?

解决方案

This depends a great deal on how you're resolving collisions. If you user linear probing, performance usually starts to drop pretty badly with a load factor much higher than 60% or so. If you use double hashing, a load factor of 80-85% is usually pretty reasonable. If you use collision chaining, performance usually remains reasonable with load factors up to around 150% or or more.

I've sometimes even created a hash table with balanced trees for collision resolution. In this case, you can almost forget about re-hashing -- the performance doesn't start to deteriorate noticeably until the number of items exceeds the table size by at least a couple orders of magnitude.

这篇关于我应该在什么时候做的老调重弹整个哈希表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 00:43