Hash Table Simulator
A hash table maps a key to a bucket index using a hash function. This simulator resolves collisions with separate chaining, so each bucket stores a small list of key-value entries.
Hash table operations
Current hash calculation
Example hash table loaded. Choose an operation.
Operation trace
- No operation yet.
History
- No operations yet.
Hash table concepts
Hash distribution
A good hash function spreads similar keys across different buckets. This simulator uses a rolling multiplication-and-XOR hash rather than simply summing 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 divided by 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 use strict string equality.
Complexity summary
| Operation | Average | Worst case |
|---|---|---|
| Insert / Update | O(1) | O(n) |
| Lookup | O(1) | O(n) |
| Delete | O(1) | O(n) |
| Resize / Rehash | O(n) | O(n) |
| Space | O(n + m) | O(n + m) |