HomeAbout

Hash Table

Characteristic

Hash table stores key-value pairs but the key is generated through a hashing function.

  • That makes accessing the data faster as the index value behaves as a key for the data value.

In Python, the Dictionary data types represent the implementation of hash tables.

Hashing function

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.
  • The values are usually used to index a fixed-size table called a hash table.

Hash functions and their associated hash tables are used in data storage and retrieval applications to access data in a small and nearly constant time per retrieval.

Hash table vs Associative array

The term "hash table" is talking about the implementation: a specific way to organize your data in memory.

The term "associative array" is talking about the interface: the concept that you use objects as array indices. (This is sometimes called an abstract data structure.)

There are multiple ways to implement an associative array. A hash table is one of them -- in fact, it is by far the most common one.

AboutContact