Next:3.5.2
Multiplication MethodUp:3.5
Hashing FunctionsPrevious:3.5
Hashing Functions
3.5.1 Division Method
-
A key is mapped into one of m slots using the function
h(k) = k mod m
-
Requires only a single division, hence fast
-
m should not be :
-
a power of 2, since if m = 2p, then h(k)
is just the p lowest order bits of k
-
a power of 10, since then the hash function does not depend on all the
decimal digits of k
-
2p - 1. If k is a character string interpreted in radix
2p, two strings that are identical except for a transposition
of two adjacent characters will hash to the same value.
-
Good values for m
-
primes not too close to exact powers of 2.
eEL,CSA_Dept,IISc,Bangalore