MIT Introduction to Algorithms Record-8
来源:互联网 发布:卡洛斯实况巅峰数据 编辑:程序博客网 时间:2024/04/30 11:22
Weakness of hashing: For any choice of hash function, it always exist bad set of keys that all hash to same slot.
Idea: Choose hash function at random,independently from the keys.
Universal Hashing
Definition1: Let
So
I.e. if
Theorem1:
Choose
Proof:
Let
Note:
So:
Constructing a universal hash function
Let
in here we treating
Now we’re going to pick an
Definition2:
We want to know how big is the set of hash function here? how many different hash functions do I have in this set?
Conclusion:
Explanation:
Because it have
Theorem2:
Proof:
Let
Question: How many hash functions in universal
It must have
since
Number Theory Fact:
let
m be prime, for anyz∈Zm (Zm are intergers module m) , so for anyz is not congruent to 0, there exists a uniquez inverse inZm , such that if I multiplyz times the inverse, it produces something congruent to one modm .
I.e..$z≢0,∃ unique z−1∈Zm ⇒$zz−1≡1 (mod m)
Conclusion:
Thus, for any choice of
So the number of
because
Perfect Hashing
Situation: Given
Idea: Use a 2-level scheme with universal hashing at both levels. And the idea is that we’re going to do it in such a way that we have no collisions at level 2 and we’ll take any collides at level 1.
If
Level-2 Analysis
Theorem: Hash
Proof: Probability 2 given keys collide under
Note:
Markov inequality
For randomly variable
x≥0, Pr{x≥t} ≤ E[x]t .
Proof:
Corollary:
Now we can use the Markov inequality theorem to prove that the corollary is correct.
Proof:
Conclusion: So we can know that to find a good level-2 hash function, just test a few at random, and we’ll find one quickly since at least half will work.
Analysis of storage
For level-1 choose
E[total storage]=n+E[∑i=0m−1θ(n2i)]=θ(n)
Note: we can get
- MIT Introduction to Algorithms Record-8
- 麻省理工学院《算法导论》(MIT - Introduction to Algorithms)
- Introduction to C++ MIT
- Ex 9.3-8 of Introduction to algorithms
- About Introduction to Algorithms
- Introduction to Algorithms
- Introduction to Algorithms
- BUBBLESORT: INTRODUCTION TO ALGORITHMS
- Introduction to Algorithms
- 开始学习MIT课程6.046J / 18.410J Introduction to Algorithms (SMA 5503), Fall 2005
- 麻省理工学院《算法导论》(MIT - Introduction to Algorithms) 视频教学下载地址
- introduction to algorithms 菜鸟笔记 sort algorithms
- Introduction to String Searching Algorithms
- 《Introduction to Algorithms》Second Edition
- Book "Introduction to Algorithms" Got
- introduction to algorithms 笔记 AVLtree
- Introduction To Algorithms Chapter6(Heapsort)
- HeapSort implementation (Introduction to Algorithms)
- Unity3D:Compate Shader
- bootstrap的日期选择器插件
- mycat是什么鬼?垂直切分?水平切分?
- centos安装Samba服务器
- Android开发用过的十大框架
- MIT Introduction to Algorithms Record-8
- 物流营销服务
- 重定向NSLog
- 函数柯里化
- "二叉树"-实现数据结构算法,完全解析,通俗易懂的图文及代码讲解
- powershell复制目录结构和删除空目录
- 第四部分 linux led驱动代码分析
- Ignoring InnerClasses attribute for an anonymous inner class
- 回溯法解决批处理作业调度问题