Hash tables are one of the most used data structures when
developing applications (the reader is advised to type this term in any
search engine and see the number of found links). There are multiples
libraries in almost any programming language providing efficient
implementations of these tables (i.e. the java.util.Hashtable
class which is part of the Java libraries).
A hash table implementation is based on the following elements:
A reasonably sized table to store the (key, value) pairs.
A “hash” function that receives a key and returns an index to access a table position.
A procedure to treat the cases in which the previous function returns the same index for two different keys. This situation is known with the term collision.
The implementation of each of these three elements offers a huge number of possibilities, turning into as many possible implementations of a hash table. It follows a detailed description of one possible solution for handling the collisions.
Answer the following questions to see if you understood what the content of this document:
A hash
function is
In a hash
table, a collision happens when: