hash table

hash tables

这里写图片描述

如图所示,使用一个hash function将原来的key映射到hash表中。碰撞发生在不同的key映射到了同一个位置。

hash function

division method

h(k)=kmodm

multiplication method

这里写图片描述

Universal hashing

选择一组hash函数,这个组合称为 universal 如果对于每个hash函数来说,它碰撞的概率小于 |h|/m 也就是说,整体的碰撞的概率小于1/m,m是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函数 h ,并且hash n keys into a table T of size m。如果k不在table中,那么 E[nh(k)]最大是 α=n/m ,如果k在table中,那么是 1+α

这个结果是不依赖于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.

这里写图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值