DEFINITION:-
Multiplicative hashing sets the
hash index from the fractional
part of multiplying k by a large
real number. It's faster if this
computation is done using fixed
point rather than floating point.
Formula:
h(K) = floor (M (kA % 1))
Here,
M is the size of the hash table. K is the key
and A can be any constant value between 0
and 1. Both k and A are multiplied and their
fractional part is separated. This is then
multiplied with M to get the hash value.
Example:
k = 12345
A = 0.357840
M = 100
h(K)=floor(M (KA % 1))
h(12345) = floor[ 100 (12345*0.357840 %
1)]
= floor[ 100 (4417.5348 mod 1) ]
= floor[ 100 (0.5348) ]
= floor[ 53.48 ]
= 53
Mid-Square hashing is a hashing
technique in which unique keys are
generated. In this technique, a seed value is
taken and it is squared. Then, some digits
from the middle are extracted. These
extracted digits form a number which is
taken as the new seed.
Suppose a 4-digit seed is taken.
seed = 4765
Hence,
square of seed is = 4765 * 4765 = 22705225
So, the new seed value becomes seed = 7052
square of this new seed is = 7052 * 7052 = 49730704
So, the new seed value becomes seed = 7307
.
.
.
.
This process is repeated as many times as a key is
required.
BY
TONIA C.S

HASHING FUNCTIONS.pptx

  • 2.
    DEFINITION:- Multiplicative hashing setsthe hash index from the fractional part of multiplying k by a large real number. It's faster if this computation is done using fixed point rather than floating point.
  • 3.
    Formula: h(K) = floor(M (kA % 1)) Here, M is the size of the hash table. K is the key and A can be any constant value between 0 and 1. Both k and A are multiplied and their fractional part is separated. This is then multiplied with M to get the hash value.
  • 4.
    Example: k = 12345 A= 0.357840 M = 100 h(K)=floor(M (KA % 1)) h(12345) = floor[ 100 (12345*0.357840 % 1)] = floor[ 100 (4417.5348 mod 1) ] = floor[ 100 (0.5348) ] = floor[ 53.48 ] = 53
  • 6.
    Mid-Square hashing isa hashing technique in which unique keys are generated. In this technique, a seed value is taken and it is squared. Then, some digits from the middle are extracted. These extracted digits form a number which is taken as the new seed.
  • 7.
    Suppose a 4-digitseed is taken. seed = 4765 Hence, square of seed is = 4765 * 4765 = 22705225 So, the new seed value becomes seed = 7052 square of this new seed is = 7052 * 7052 = 49730704 So, the new seed value becomes seed = 7307 . . . . This process is repeated as many times as a key is required.
  • 8.