algorithm - When building a hash table using linear probing for collision resolution, is the extra term always added to the hash or only when a collision occurs? -
I am creating a table, where a collision occurs when attempting to insert a new key in the table, follow the sequence Does {hash (x) + i, where i = 1,2,3, ...}. If I am creating a hash table using linear probes then my inclusion () algorithm would be something like this:
hashvalue = hash (x) while hash value in the hash value table = 1
Where I add only the increment value when the collision, or when I = 1, then something like this will start when the scale of the pay scale has to be added:
hash value = hash (x) + 1 hash value in hash value table U + = 1
Unless you do it continuously, it does not matter . The effect of adding a (or any other constant, for that matter) to hash has no effect on the structure of the table, except that the bucket numbering will be "transferred" by a constant "offset". Since bucket numbering is a personal thing of your table, nobody should pay attention.
In short, a linear probing hash function is
h (x, i) = (h (x) + i)% n
Where N
is the number of buckets, it is conventional to start at i
zero, which means that when you get a confrontation, only the value of the hash Increase in
Comments
Post a Comment