Algorithms

Hash function

A calculation that turns a key into a number. In a hash table, that number divided by the number of buckets gives the spot where it's stored.

Example

With 100 buckets and hash(key) = key, the key 12836 goes to bucket 12836 % 100 = 36.

Test yourself: Hash function

Hash tables

With 100 buckets and hash(key) = key, the key 4521 goes to bucket ___.

Lessons that use it

More algorithms terms

All terms →

Arki, the beaver mascot

Your next interview starts with 5 minutes today.

Free on iOS and Android. Start from zero, no account needed.