← Back

Hash Table Simulator

What is a Hash Table?

A hash table maps a key to a bucket index using a hash function. This simulator resolves collisions with separate chaining: each bucket stores a small list of key–value entries.

Average insertO(1)
Average lookupO(1)
Worst caseO(n)
Collision methodSeparate chaining

Hash table operations

400 ms

Current hash calculation

hash(key) = FNV-style rolling hash mod capacity

Example hash table loaded. Choose an operation.

Items0
Capacity8
Load factor0.00
Occupied buckets0

Operation trace

  1. No operation yet.

History

  1. No operations yet.

Hash table concepts

Hash distribution

A good hash function spreads similar keys across different buckets. This version uses a rolling multiplication-and-XOR hash instead of simply adding character codes.

Separate chaining

Colliding keys remain in the same bucket as separate entries. Lookup compares keys only inside the calculated bucket.

Load factor

The load factor is items / capacity. When enabled, the table doubles near 0.75 and reinserts every entry into the new bucket array.

Updating keys

Inserting an existing key changes its value without increasing the item count. Keys are compared with strict string equality.

Complexity summary

OperationAverageWorst case
Insert / UpdateO(1)O(n)
LookupO(1)O(n)
DeleteO(1)O(n)
Resize / RehashO(n)O(n)
SpaceO(n + m)O(n + m)