3. (20 points) Simple Uniform and Universal Hashing
a) (3 points) Suppose we use a hash function h to hash n distinct keys into an array T of length M. Assuming simple uniform hashing, what is the expected number of collisions?
b) For prime p, integer M > 0, and {0,.,p-1}, define the function ha=axmod pmod M. Consider the hash function family H = {ha}.
i) (2 points) Find |H|, the number of unique functions in H.
ii) (10 points) Show that, for any k, the following holds: 2|H Pr[hak=hak] M. Hint: Count the number of a's that cause collisions in ha and use the number theoretic fact of multiplicative inverses.
iii) (2 points) State whether H is universal. Justify your answer.
c) (3 points) A hash function h : U{0,..,M-1} is said to be perfect for a set K U if h does not cause any collisions among the keys in K. Prove that, for any fixed set K of size at most M, there exists a hash function h that is perfect for K.
4. Bloom filters. Suppose you are given a Bloom filter of size m with t hash functions (each of which can be assumed to be computed in O(1) time) and n inserted elements. Let S be the set representing the keys being stored.
a) (1 point) Assuming simple uniform hashing, what is the expected time (in terms of t)?
b) (3 points) Between using Bloom filters and hashing with chaining, how would you determine which has the better search time if α = n/m is fixed and t is the only variable.
c) Recall that the probability of a false positive is upper bounded by the following value: p = 1 - e^(-αt).
i) (5 points) What is the number of hash functions required to get a false positive rate of at most 0.02 if m = 100 and n = 10?
ii) (7 points) For any given fixed load factor α = n/m, find the number of hash functions that will minimize the false positive rate. (Hint: differentiate p)
d) (4 points) The standard Bloom filters discussed in class do not support deletion operations. Without changing the number m of array slots, describe a way to modify the data structure to allow for deletions and explain how this modification enables deletion to work.