How Quadratic Probing works?

Let hash(x) be the slot index computed using the hash function.

  • If the slot hash(x) % S is full, then we try (hash(x) + 1*1) % S.
  • If (hash(x) + 1*1) % S is also full, then we try (hash(x) + 2*2) % S.
  • If (hash(x) + 2*2) % S is also full, then we try (hash(x) + 3*3) % S.
  • This process is repeated for all the values of i until an empty slot is found.

Quadratic Probing in Python

Hashing is an improvement technique over the Direct Access Table. The idea is to use a hash function that converts a given phone number or any other key to a smaller number and uses the small number as the index in a table called a hash table

Similar Reads

What is Quadratic Probing?

Quadratic probing is a technique used in hash tables to resolve collisions that occur when two different keys hash to the same index. It’s a variation of open addressing, where an alternate location is searched within the hash table when a collision occurs. In quadratic probing, when a collision happens, instead of simply moving to the next slot linearly (as in linear probing), the algorithm searches for the next available slot by using a quadratic function....

How Quadratic Probing works?

Let hash(x) be the slot index computed using the hash function....

Approach: Simple Quadratic Probing

Use a quadratic function to find the next available slot when a collision occurs....

Implementation of Quadratic Probing:

Below is the implementation of Quadratic Probing in Python:...