0
Entries
0
Collisions
0
Max Depth
0
Load Factor

Hash log

How hash tables work

A hash table stores data in buckets. A hash function maps each key to a bucket index using modulo.

A collision happens when two keys land in the same bucket. Good hash functions spread keys evenly; bad ones (like using string length) cluster them.

Try these experiments:

  • Switch to length hash and add words of different lengths -- see how same-length words always collide
  • Switch to charSum and add anagrams (listen, silent) -- they collide because they have the same character sum
  • Slide the bucket count down to 2 and watch collisions pile up
  • Compare djb2 vs FNV-1a distribution on the same words