PR 9
PR 9
Problem 1. Let [m] denote the set {0, 1, 2 . . . , m − 1}. For each of the following families of hash
functions, say whether or not it is universal, and determine how many random bits are needed to
choose a function from the family.
2. H is the same as before except that m = 2k , for some fixed positive integer k.
1
Solution. (1) is universal. The proof is very similar to what has been done in the class (where we
used a four tuple). To repeat the argument, we have to calculate the probability that h(x1 , x2 ) =
h(y1 , y2 ), given that (x1 , x2 ) 6= (y1 , y2 ). Assume that x2 6= y2 . Then, the above equation is
a1 x1 + a2 x2 = a1 y1 + a2 y2 mod m
or, that
a1 (x1 − y1 ) = a2 (y2 − y1 ) mod m .
Since, m is prime, and y2 6= y1 , y2 − y1 has an inverse modulo m, which fixes a2 in the above
1
equation (modulo m). Thus, Pr(h(x1 , x2 ) = h(y1 , y2 )) = m , since, a1 can take any value, but that
fixes exactly 1 out of m values of a2 . Hence, the probability (if a1 , a2 are chosen randomly) that
1
h(x1 , x2 ) = h(y1 , y2 ) is m .
(2) Now suppose m = 2k . Then, y2 − y1 if non-zero need not have an inverse, if it is even (for
example). So H is not universal.
(3) H is the set of all functions from [m] to [m − 1]. So, for x 6= y, h(x) = h(y) has how many
solutions? Since, h(x) = h(y), x, y together get mapped to the same value in m − 1 ways. Every
other value z ∈ [m] \ {x, y} gets mapped in m − 1 ways. Total is (m − 1)m−2+1 = (m − 1)m−1 . The
possible number of hash functions, that is, the size |H| = (m − 1)m . Hence, the probability is