Hash Tables for Integer Keys in Data Structure

Data StructureAnalysis of AlgorithmsAlgorithms

Here we will discuss about the Hash tables with the integer keys. Here the key values 𝑥 comes from universe 𝑈 such that 𝑈 = {0, 1, … , 𝑢 – 2, 𝑢 – 1}. A hash function is ℎ. The domain of this hash function is 𝑈. The range is in the set {0, 1, … , 𝑚 – 1}, and 𝑚 ≤ 𝑢.

A hash function h is said to be a perfect hash function for a set 𝑆 ⊆ 𝑈 if for every 𝑥 ∈ 𝑆, ℎ(𝑥) is unique. A perfect hash function ℎ for 𝑆 is minimal if 𝑚 = |𝑆|. So ℎ is bijection between S and {0, 1, … , 𝑚 – 1}. Obviously a minimal perfect hash function is desirable since this allows us to store all the elements of S in a single array of length n.

Unfortunately, perfect hash functions are very rare, even if m is much larger than n. If each element in S is uniformly and independently mapped to a random element in {0, 1, … , 𝑚 – 1}, then according to birthday paradox if m is much less than n2 then there will almost surely exists two elements of S, that have the same hash value.

Published on 10-Aug-2020 12:46:29