[Math] Universal Hashing

computer sciencehash function

to my current understanding Universal Hashing is a method whereby the hash function is chosen randomly at runtime in order to guarantee reasonable performance for any kind of input.

I understand we may do this e.g. in order to prevent manipulation by somebody choosing malicious input deliberately (a possibility of a deterministic hash function is know).

My Question is the following: Is it not true, that we still need to guarantee that a key will be mapped to the same address every time we hash it ? For instance if we want to retrieve information, but the hash function is chosen at random, how do we guarantee we can get back at our data ?

Best Answer

Once the hash function has been chosen for a given key, the key ought to remain in that slot. The whole point of a class of universal hash functions is that the runtime for data retrieval is expected to be significantly less than the worst case in a basic hash using chaining. Specifically, it can be shown that the expected length of the linked list corresponding to an arbitrary key is equal to $1+\frac{n}{m},$ where $n$ is the number of keys and $m$ is the number of slots (cf. Cormen et. all.) Perhaps I don't fully understand your question though.

Related Question