HASHING
 Hashing is the process of
transforming any given key or a
string of characters into
another value
FIG:1
LINEAR PROBING
 In linear probing, the hash table is searched sequentially that
starts from the original location of the hash. If in case the
location that we get is already occupied, then we check for the
next location.
The function used for rehashing is as follows:
hash(key) = (key)%table-size
Example:
 A simple hash function as “key
mod 7” and a sequence of keys as
50, 700, 76, 85, 92, 73, 101
which means hash(key)= key% S,
here S=size of the table=7, and
indexed from 0 to 6.
FIG:2
INSERT ‘50’:
hash(key) = (key)%table-size
=> hash(50)= 50%7
= 1
So, ‘50’ will store at ‘1’ position.
FIG:3
INSERT ‘700’ and ‘76’:
hash(key) = (key)%table-size
=> hash(700)= 700%7
= 0
So, ‘700’ will store at ‘0’
position.
=> hash(76)= 76%7
= 6
So, ‘76’ will store at ‘6’ position.
FIG:4
COLLISION
 A hash collision or hash
clash is when two pieces
of data in a hash table
share the same hash
value.
FIG:5
INSERT ‘85’:
hash(key) = (key)%table-size
=> hash(85)= 85%7
= 1
As, ‘1’ position is already filled
so search for next empty position
and store it. So, the ‘85’ will be
placed at ‘2’ position.
FIG:6
FIG:7 FIG:8
linear probing.pptx

linear probing.pptx

  • 3.
    HASHING  Hashing isthe process of transforming any given key or a string of characters into another value FIG:1
  • 4.
    LINEAR PROBING  Inlinear probing, the hash table is searched sequentially that starts from the original location of the hash. If in case the location that we get is already occupied, then we check for the next location. The function used for rehashing is as follows: hash(key) = (key)%table-size
  • 5.
    Example:  A simplehash function as “key mod 7” and a sequence of keys as 50, 700, 76, 85, 92, 73, 101 which means hash(key)= key% S, here S=size of the table=7, and indexed from 0 to 6. FIG:2
  • 6.
    INSERT ‘50’: hash(key) =(key)%table-size => hash(50)= 50%7 = 1 So, ‘50’ will store at ‘1’ position. FIG:3
  • 7.
    INSERT ‘700’ and‘76’: hash(key) = (key)%table-size => hash(700)= 700%7 = 0 So, ‘700’ will store at ‘0’ position. => hash(76)= 76%7 = 6 So, ‘76’ will store at ‘6’ position. FIG:4
  • 8.
    COLLISION  A hashcollision or hash clash is when two pieces of data in a hash table share the same hash value. FIG:5
  • 9.
    INSERT ‘85’: hash(key) =(key)%table-size => hash(85)= 85%7 = 1 As, ‘1’ position is already filled so search for next empty position and store it. So, the ‘85’ will be placed at ‘2’ position. FIG:6
  • 10.