Learn practical skills, build real-world projects, and advance your career

Python Hash Tables, Linear Probing and Dictionaries

Hashing Function:

A hash function is any function that can be used to map data of arbitrary size to fixed-size values. The values returned by a hash function are called hash values, hash codes, digests, or simply hashes. The values are usually used to index a fixed-size table called a hash table. source

Hash Tables:

When the hashes obtained from hash functions somehow used as indices of a list/array then this list is known as hash tables.

Python Dictionaries

Python dictionaries are implemented using hash tables.

We are going to create a Hash Table class which will have methods to following operations:

  1. Insert: Insert a new key-value pair
  2. Find: Find the value associated with a key
  3. Update: Update the value associated with a key
  4. List: List all the keys stored in the hash table

The Hash Table so obtained will have following signature.