Hashing
- Hashing fundamentals
- Application: Unordered sets
- Hash table with chaining
- Practical universal hash functions
- Application: Coordinated sampling
1. Hashing fundamentals
-
Notation:
-
For n ∈ N n\in N n∈N:
[ n ] = { 0 , . . . , n − 1 } [n]=\{0,...,n-1\} [n]={ 0,...,n−1}
[ n ] + = { 1 , . . . , n − 1 } [n]_+=\{1,...,n-1\} [n]+={ 1,...,n−1}
-
Expectation of indicator variable:
E [ X ] = P r [ X = 1 ] E[X]=Pr[X=1] E[X]=Pr[X=1]
E [ ∑ i X i ] = ∑ i E [ X i ] E[\sum_iX_i]=\sum_iE[X_i] E[∑iXi]=∑iE[Xi]
-
1.1 Hash function
Given a universe U U U of keys, and a positive integer m m m.
Definition
-
A (random) hash function h : U → [ m ] h:U\rightarrow[m] h:U→[m] is a randomly chosen function from U → [ m ] U\rightarrow [m] U→[m]. Equivalently, it is a function h h h such that for each x ∈ U , h ( x ) ∈ [ m ] x\in U,h(x)\in[m] x∈U,h(x)∈[m] is a random variable.
(We randomly project the original U U U to a set of [ m ] [m] [m])
-
Three things we care about:
- Space need to represent h h