Starting from:
$30

$24

Homework 07: Double Hashing Solution




Instruction




Submit your answer to this question via PC^2 under your account by the posted due time. No late submissions will be accepted. Note that homework is opened-book, but no outside assistance is permitted.




Problem




Double hashing greatly reduces clustering and is one of the best methods for hashing in open-addressed schemes. It uses two auxiliary pre-hashing




functions




h1 ( k)




and




h2 ( k )




, such that the hashing function h ( k , i ) is of the form:









h( k , i )  [ h1 ( k )  i  h2 ( k )]mod m










The initial probe goes to the position of h1 ( k) and all subsequent probes go to






integer multiples of







h2 ( k )







positions further. Write a program that returns



message when a collision has been detected during insertion. Note that the size of hash table is fixed as 13 in this problem.




Sample input




12,26,31,17,90,28,88,40,77







Sample output




Collision has occurred for element 90 at position 12 finding new Position at position 6




Collision has occurred for element 77 at position 12 finding new Position at




position 11




Done

More products