write a short paper on double hashing A paper must describe
write a short paper on double hashing
A - paper must describe the process of double hashing. Paper must state why this process is named double hashing. Paper must indicate what role the second hash function plays in the algorithm Paper must state the pros and cons of double hashing (speed/Big O/other). Paper must include examples of where double hashing is used. Paper must mention at least one variation on double hashing
Solution
Double Hashing :
This paper invovles the role and process of double hashing ,role of second hash function.Pros and cons of double hashing and example of double hashing.
Double hashing is a computer program technique that used in hash table to resolve the collision.It is also known as rehashing.It is popular collision-resolution technique.in open address hash table.
The variation on Double hashing is bloom filters.Building a better bloom filter deals with less hashing better performance
*Process of double hashing:
Double hashing works on a similar idea of linear and quadratic probing.It uses a big table and hash table into it.Whenever a collision occur ,it choose another spot to put the value in the table.But double hashing uses a second hash function to determine the location of the next spot.
EX:Suppose we have hash functions Hash1 and HAsh2 & key .then process of double hashing is as follows:
1]check location Hash1(key).If it is empty then put record in it.
2]If location is not empty,then calculate Hash2(kay).
3]check if Hash1(key)+Hash2(key)is open,if yes, then put records in it.
4]Repeat with Hash1(key)+2Hash2(key),Hash1(key)+2Hash2(key) & so on,till an open location is not found.
Double hashing uses the idea of applying second hashing function to the key when a collision occurs.The result of the second hashing function will be the number of position form the point of collision to insert.That why it is called as Double hashing.
The role of second hashing function is very important in double hashing.Because when collision occurs double hashing use second hash function to key .The second hash function results into number of position form the point of collision to insert.
When collision insert at next available location.Probs is used to locate next spot.
ith probed location=(h(k)+f(i))%p
wheref(0)=0 and f(i)=i is probing function.
Then linear probing:f(i)=i,cons:Give primary clustring of data arround popular bucket.Where lambada>1/2,A ton of cache misses when lambda gets large.
pros:Insert guaranteed to succeed when lambda < 1.
The quadratic probing:f(i)=i^2,cons:requires lower load factor,suffer from secondary clustring.
pros:Success guaranteed when lambda<1/2.
where lambda (a load factor)is a average number of item hashed to a bucket and lambda<2
double hashing:f(i)=another hash function, probs:Reduces chances of key colliding ,will succesed when lambda<1&h(k)=k%p.
Ex for Double hashing:
Total size=10 element
Hash1(key)=key%10
Hah2(key)=7-(k%7)
insert keys=89,18,49,58,69
Hash(89)=89%10=9
Hash(18)=18%10=8
Hash(49)=49%10=9 a collision
=7-(49%7)
=7 position from [9]
Hash(58)=58%10=8
=7-(58%10)
=7 position from [8]
Hash(69)=69%10=9
=7-(69%7)
=1 position from [9]
.

