Learn CS Visual

How Hash Tables Work

A hash table stores each key in the bucket numbered by a hash function — for example key % 5. When different keys map to the same bucket number, it is called a collision, and colliding keys are chained together in a linked list within that bucket.

Inserting key 18, which bucket number does it land in?