4

I read in our university lecture on hashing that it would be good (even though it is way to space intensive) if we could take the set of all function from $U \rightarrow V$ to satisfy the following universal hashing condition: for all $\forall x,y\in U$ so that $x≠y$, we have $Pr[h(x)=h(y)]≤\frac{1}{|V|}$

I actually don´t understand why the set of all functions would satisfy our condition. I can definitively see that there are some function which fit this condition, but I can think of other functions which dont meet the condition. So I would have to make a statement about average probabilty over the set of all functions, but how could something like this be defined precisely?

Or am I taking something wrong here and the Set of all functions wouldn´t meet the condition, but would actually be better that the condition taking the case that h is taking randomly from H? Even if so it seems to come down to the same problem.

OuttaSpaceTime
  • 195
  • 1
  • 7

1 Answers1

4

First note that the set of all functions $U\to V$ contains for every value $u\in U$ and every value $v\in V$ a function $f$ such that $f(u)=v$. Also note that if you fix a point $u\in U$ and take a random function from $U\to V$, $f(u)$ is uniformly distributed in $V$.

Now if you apply that, fix any two points $x\neq y,\quad x,y\in U$. Now choose $h$ randomly out of $U\to V$. Note that $h(x)$ is uniformly distributed and $h(y)$ is uniformly distributed. The probability for $h(x)$ and $h(y)$ to be equal now should be $1/|V|$ which implies the desired universality.


Given that the above might not be entirely clear, let's do an example: $$U=\{1,2,3\}\quad V=\{1,2,3\}$$ Clearly there are 27 functions mapping from $U$ to $V$ and clearly there are 6 pairs of unequal values $(x,y)\in U\times U$ for which we need to check whether the probability holds.

  • $(x,y)=(1,2):$ There are three possible ways to map $1$: to either 1,2, or 3, let's denote the actual value $h(x)$ for the moment. There are also three possible values to map $2$ to: 1,2, or 3, let's denote the actual value as $h(y)$. Given that these two choices are independent, there are 9 cases here.

    • If $h(x)=1$ then the tested equation only holds if $h(y)=1$ as well which is a 1/3 chance
    • If $h(x)=2$ then the same argument as for $h(x)=1$ applies with $h(y)=2$
    • $h(x)=3$ goes analogously

Now counting the cases where the equation holds for $(x,y)=(1,2)$ we get $3/9\leq 1/3$ as demanded.

If we go through the other pairs as well, a very similar argument will ensue and we'll be getting $3/9$ for all of them. Therefore a random function from $U$ to $V$ satisfies universality.

SEJPM
  • 46,697
  • 9
  • 103
  • 214