【发布时间】:2019-08-29 09:31:11
【问题描述】:
我从 CLRS(Cormen 等人)开始学习散列。我能够理解数学过程以及计算机实现的方式。这本书简单地将数学过程描述为-
-> multiply the key k with a constant A (0<A<1), results into kA;
-> extract the fractional part of kA by doing (kA mod 1);
-> multiply the result with m (usually taken to be a power of 2 for easy
implementation on computers);
-> take the floor of this result and that is the hashed value;
-> therefore, this is the hashing function, h(k) = floor[m*(kA mod 1)]
这本书进一步说明了它将如何在大多数计算机上实现,它优于除法方法和 Knuth 对“A”值的建议。
我无法理解的是,为什么我们要遵循这个程序,即专门将密钥与 0 到 1 范围内的数字 (A) 相乘,然后取小数部分,然后乘以 m,然后取地板?
这是否会产生“非常类似于”SUHA(简单统一散列假设)的散列值,即理想情况下每个键都应该独立散列到 m 个插槽中的任何一个,那么这种方法会产生“更接近”这个理想的结果吗?
【问题讨论】:
标签: methods hash hashtable multiplication