math - 二次探测 : (f(k) + a*j + b*j^2) % M, 如何选择a和b?

标签 math hash

如果 M 是质数,如何选择 a 和 b 以最小化碰撞?

书上也写到,要在 (f(k)+j^2) % M 中进行二次探测时找到空槽,哈希表必须至少有一半是空的?有人可以向我提供证明吗?

最佳答案

wikipedia 上选择 a 和 b 有一些值:

For prime M > 2, most choices of a and b will make f(k,j) distinct for j in [0,(M − 1) / 2]. Such choices include a = b = 1/2, a = b = 1, and a = 0,b = 1. Because there are only about M/2 distinct probes for a given element, it is difficult to guarantee that insertions will succeed when the load factor is > 1/2.

保证找到空槽的证明是herehere .

关于math - 二次探测 : (f(k) + a*j + b*j^2) % M, 如何选择a和b?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1432386/

相关文章:

java - 生成添加到目标的所有数学表达式组合(Java作业/面试)

c# - 寻找将负整数归零的 .NET Math 方法

c - 调整哈希 C 大小时发生内存泄漏

php - 用PHP实现Rabin-Karp算法

algorithm - 为什么在 Hashing 中主集群的上下文中,空槽之前是 i 个满槽的概率是 (i + 1)/m?

java - 用于 java 或 scala 中整数分解的库

python - Python 中用于 float 的内置 pow() 和 math.pow() 之间的区别?

python - Python 和 Excel 中 TAN(X) 的错误值

Javascript 迭代哈希错误

ruby - 使用正则表达式找不到哈希键值