Add/Remove & Search in Hash Table (Implementation)
Explore how to implement key hash table operations including insertion, search, and deletion in Python. Understand dynamic resizing to avoid collisions and maintain efficient average case performance for these operations.
We'll cover the following...
We'll cover the following...
In the previous lesson, we built a HashTable class and designed a hash function. Using that code, we will implement the main functionalities of a hash table.
Resizing in a Hash Table
To start things off, we will make sure that the hash table doesn’t get loaded up beyond a certain threshold. Whenever it crosses the threshold, we shift the elements from the current table to a new table with double the capacity. This helps us avoid collisions.
To implement this, we will make the resize() function.
Have a look at
resize()...