# Hashing by Multiplication in Data Structure

Data StructureAnalysis of AlgorithmsAlgorithms

#### Big Data Hadoop

Best Seller

89 Lectures 11.5 hours

#### Practical Data Science using Python

22 Lectures 6 hours

#### Data Science and Data Analysis with Python

50 Lectures 3.5 hours

Here we will discuss about the hashing with multiplication method. For this we use the hash function −

ℎ(𝑥) = ⌊𝑚𝑥𝐴⌋ 𝑚𝑜𝑑 𝑚

Here A is a real-valued constant. The advantage of this method is that the value of m is not so critical. We can take m as power of 2 also. Although any value of A gives the hash function, but some values of A are better than others.

According to Knuth, we can use the golden ratio for A, So A will be

$$A=\frac{\sqrt5-1}{2}=0.61803398$$

Of course, no matter what value is chosen for A. The pigeonhole principle implies that if u ≥ nm, then there will be one hash value i and some S ⊆ U of size n, such that h(x) = i for all x in S.

So we can say that the worst case hashing by multiplication is as bad as hashing by division.