hash table
hash tables
如图所示,使用一个hash function将原来的key映射到hash表中。碰撞发生在不同的key映射到了同一个位置。
hash function
division method
multiplication method
Universal hashing
选择一组hash函数,这个组合称为 universal 如果对于每个hash函数来说,它碰撞的概率小于
In universal hashing, at the beginning of execution we select the hash function at random from a carefully designed class of functions.
在universal hashing中,从一组精神设计的hash function中选择。
Theorem
假设从一组hash函数的universal collection随机挑选了一个hash函数
这个结果是不依赖于hash函数的选择的,也就是说,当碰撞的时候采取chaining的方法,那么当hash一个k到表中时,当它不在表中,它在的slot的 长度的平均值 是 n/m,如果k在表中是 1 + n/m(就是1 + 不在的平均长度)
it has now become impossible for an adversary to pick a sequence of operations that forces the worst-case running time. By cleverly randomizing the choice of hash function at run time, we guarantee that we can process every sequence of operations with a good average-case running time.