Hashing

Basic idea:

store key or key/data record pairs in an array, called a "hash table"

make the hash table size comparable to the number of actual keys that will be stored in it  typically
much
smaller than the number of possible key values

given a key, compute the index of that key’s location in the array using a fast O(1) function, called a "hash function"

Since the hash function is O(1), a hash table has the potential for very fast find performance (the best possible!), but...

... since the hash function is mapping from a large set (the set of all possible keys) to a smaller set (the set of hash table locations) there is the possiblity of
collisions
: two different keys wanting to be at the same table location
CONTENTS PREVIOUS NEXT