Hash Function

noun

say it: “HASH FUNK-shun” /hæʃ ˈfʌŋkʃən/

A recipe that turns a key into a number, giving the same key the same number every time, so a hash table knows which bucket to use.

What is a hash function?

A hash function turns a key, such as a name, into a number that picks a hash table's bucket. A good one gives the same key the same number every time, takes only a few steps, and spreads keys evenly over the buckets, so few of them share.

In a sentence

  • “Our hash function only looked at a name's length, so most of the names landed in the same three buckets.”

Level: Journeyman · More Data Structures terms at this level

Updated