Math Genius: show that $h(k)=left lfloor{frac{k}{m}}right rfloor mod m$ is a bad hash function where $m$ is prime

Original Source Link

A “good” hash function should make use of all slots with equal frequency. In this case the ammount of slots is given with $m$.

Also keys which are similar should be distributed as broadly as possible.

Any ideas how to approach this excercise?

Hint. Take for instance $m = 5$ and consider the numbers $0, 1, ldots, 29$. Then you will have $10$ numbers in slot $0$, but only $5$ numbers in slots $1$, $2$, $3$, $4$. Thus taking $k bmod m$ would give a much better result.

Tagged : /

Math Genius: show that $h(k)=left lfloor{frac{k}{m}}right rfloor mod m$ is a bad hash function where $m$ is prime

Original Source Link

A “good” hash function should make use of all slots with equal frequency. In this case the ammount of slots is given with $m$.

Also keys which are similar should be distributed as broadly as possible.

Any ideas how to approach this excercise?

Hint. Take for instance $m = 5$ and consider the numbers $0, 1, ldots, 29$. Then you will have $10$ numbers in slot $0$, but only $5$ numbers in slots $1$, $2$, $3$, $4$. Thus taking $k bmod m$ would give a much better result.

Tagged : /

Math Genius: Check if element was used to construct Hash

Original Source Link

For a given set of data $D = {d_1, d_2, dots, d_n }$ is there a hash-function $f$ that for any subet $D_s subset D$

$$
f(D_s) = H_{D_s}
$$

so that a second function $g$ exisist with

$$
g(f(D_s) , d_i)= g(H_{D_s} , d_i)=begin{cases} 0, & d_i notin D_s , \ 1, & d_i in D_s, end{cases}
$$

So expressed in words: The function $g$ tells me whether or not the element $d_i$ was used to constructed the Hash $H_{D_s}$.

If there are no such functions, are there functions that fulfills the described properties with a given probability larger then 0.5

PS:
with hash function I just mean that the result of the function has a fixed size. I’m not interested in any security or reversibility properties

Tagged : /