LINEAR PROBING
M.VISHWANI
227R1A1235
Hashing is nothing but by implementing a hash
function
Hashing is a technique used for performing
insertions, deletions and finds in constant average
time
Hash table
Hash tableADT which supports only a subset of the
operations allowed by binary search trees. Hash
table structure is merely an array of some fixed
size, containing the items
 In an open addressing hashing system, all the data go
inside the table
 In open addressing,
 Unlike separate chaining, all the keys are stored inside
the hash table.
 No key is stored outside the hash table
There are three common collision resolution strategies:
 Linear Probing
 Quadratic probing
 Double hashing
Linear probing is s technique for resolving hash
collisions of values of hash function.
Linear probing is a scheme in computer
programming for resolving collisions in hash
tables, data structures for maintaining a collection
of key–value pairs and looking up the value
associated with a given key.
 Linear probing can provide high performance
because of its good locality of reference, but is more
sensitive to the quality of its hash function than some
other collision resolution schemes.
 Linear probing is a component of open
addressing schemes for using a hash table to solve
the dictionary problem.
The linear probing hash table is a fairly simple
structure where data items are stored directly
inside the hash element array. It gets its name by
the way it handles the unique problems that exist
when storing the data items in the table directly.
It takes constant expected time per search,
insertion, or deletion when implemented using a
random hash function
To insert a key–value pair (x,v) into the table (possibly
replacing any existing pair with the same key), the
insertion algorithm follows the same sequence of cells
that would be followed for a search, until finding either
an empty cell or a cell whose stored key is x.The new
key–value pair is then placed into that cell
If the insertion would cause the load factor of the table
(its fraction of occupied cells) to grow above some
preset threshold, the whole table may be replaced by a
new table, larger by a constant factor, with a new hash
function, as in a dynamic array.
InsertOperation
 Hash function is used to compute the hash value for
a key to be inserted.
 Hash value is then used as an index to store the key
in the hash table.
 In case of collision,
 Probing is performed until an empty bucket is
found.
 Once an empty bucket is found, the key is inserted.
 Probing is performed in accordance with the
technique used for open addressing.
SearchOperation
 To search any particular key,
 Its hash value is obtained using the hash function
used.
 Using the hash value, that bucket of the hash table
is checked.
 If the required key is found, the key is searched.
 Otherwise, the subsequent buckets are checked
until the required key or an empty bucket is found.
 The empty bucket indicates that the key is not
present in the hash table.
THANKYOU

DS THEORY 35.pptx

  • 1.
  • 3.
    Hashing is nothingbut by implementing a hash function Hashing is a technique used for performing insertions, deletions and finds in constant average time Hash table Hash tableADT which supports only a subset of the operations allowed by binary search trees. Hash table structure is merely an array of some fixed size, containing the items
  • 4.
     In anopen addressing hashing system, all the data go inside the table  In open addressing,  Unlike separate chaining, all the keys are stored inside the hash table.  No key is stored outside the hash table There are three common collision resolution strategies:  Linear Probing  Quadratic probing  Double hashing
  • 5.
    Linear probing iss technique for resolving hash collisions of values of hash function. Linear probing is a scheme in computer programming for resolving collisions in hash tables, data structures for maintaining a collection of key–value pairs and looking up the value associated with a given key.  Linear probing can provide high performance because of its good locality of reference, but is more sensitive to the quality of its hash function than some other collision resolution schemes.
  • 6.
     Linear probingis a component of open addressing schemes for using a hash table to solve the dictionary problem. The linear probing hash table is a fairly simple structure where data items are stored directly inside the hash element array. It gets its name by the way it handles the unique problems that exist when storing the data items in the table directly. It takes constant expected time per search, insertion, or deletion when implemented using a random hash function
  • 7.
    To insert akey–value pair (x,v) into the table (possibly replacing any existing pair with the same key), the insertion algorithm follows the same sequence of cells that would be followed for a search, until finding either an empty cell or a cell whose stored key is x.The new key–value pair is then placed into that cell If the insertion would cause the load factor of the table (its fraction of occupied cells) to grow above some preset threshold, the whole table may be replaced by a new table, larger by a constant factor, with a new hash function, as in a dynamic array.
  • 9.
    InsertOperation  Hash functionis used to compute the hash value for a key to be inserted.  Hash value is then used as an index to store the key in the hash table.  In case of collision,  Probing is performed until an empty bucket is found.  Once an empty bucket is found, the key is inserted.  Probing is performed in accordance with the technique used for open addressing.
  • 10.
    SearchOperation  To searchany particular key,  Its hash value is obtained using the hash function used.  Using the hash value, that bucket of the hash table is checked.  If the required key is found, the key is searched.  Otherwise, the subsequent buckets are checked until the required key or an empty bucket is found.  The empty bucket indicates that the key is not present in the hash table.
  • 11.