Overflow Handling in Data Structure

Data Structure AlgorithmsAnalysis of AlgorithmsAlgorithms

An overflow occurs at the time of the home bucket for a new pair (key, element) is full.

We may tackle overflows by

Search the hash table in some systematic manner for a bucket that is not full.

  • Linear probing (linear open addressing).
  • Quadratic probing.
  • Random probing.

Eliminate overflows by allowing each bucket to keep a list of all pairs for which it is the home bucket.

  • Array linear list.
  • Chain.

Open addressing is performed to ensure that all elements are stored directly into the hash table, thus it attempts to resolve collisions implementing various methods.

Linear Probing is performed to resolve collisions by placing the data into the next open slot in the table.

Performance of Linear Probing

  • Worst-case find/insert/erase time is θ(m), where m is treated as the number of pairs in the table.
  • This occurs when all pairs are in the same cluster.

Problem of Linear Probing

  • Identifiers are tending to cluster together
  • Adjacent clusters are tending to coalesce
  • Increase or enhance the search time

Quadratic Probing

Linear probing searches buckets (H(x)+i2)%b; H(x) indicates Hash function of x

Quadratic probing implements a quadratic function of i as the increment

Examine buckets H(x), (H(x)+i2)%b, (H(x)-i2)%b, for 1<=i<=(b-1)/2

b is indicated as a prime number of the form 4j+3, j is an integer

Random Probing

Random Probing performs incorporating with random numbers.

H(x):= (H’(x) + S[i]) % b
S[i] is a table along with size b-1
S[i] is indicated as a random permutation of integers [1, b-1].
raja
Published on 08-Jan-2020 16:02:24
Advertisements