teach-ict.com logo

THE education site for computer science and ICT

3. Storing hashes

On the previous page, we took a data set of long integers and produced a corresponding set of hashes. The next step is to use these hashes to store the data in a hash table.

The MOD 11 calculation we used will always produce hashes between 0 and 10 (as it's not possible to have a remainder of 11). This means that the hash table only needs to have 11 slots, one for each of these possible results.

The empty hash table then looks like this:

Hash function

The hash function (MOD 11) determines which of the slots the data will go into. See this animated gif for a demonstration:

Hash function

 

Challenge see if you can find out one extra fact on this topic that we haven't already told you

Click on this link: What is a hash function