Quick Index
Overview


Numeric keys can collide as well.

In all of these examples we have set the hash table size equal to the number of keys.

Ideal Hash Table Starting at 0


Here we are lucky to have a arithmetic sequence of keys with constant step. The hashing of this ideal set of keys produces no collisions.

        Key    Hash Code   MOD 5
         0         0         0
         1         1         1
         2         2         2
         3         3         3
         4         4         4


Ideal Hash Table Starting at 1000


Here we are lucky to have a arithmetic sequence of keys with constant step. The hashing of this ideal set of keys produces no collisions.

    Key    Hash Code     MOD 5
      1000      1000         0
      1001      1001         1
      1002      1002         2
      1003      1003         3
      1004      1004         4


Sequential Ids with Gaps


Here we have a non-arithmetic sequence of keys. This set produces multiple collisions.

      Key     Hash Code   MOD 5
         1         1         1
         8         8         3
        13        13         3
        18        18         3
        23        23         3


Phone Numbers


A list of phone numbers with multiple collisions. It is of course a non-arithmetic sequence. This set produces multiple collisions.

        Key          Hash Code            MOD 5
     7859291020      730643571              1
     4792020999      497053702              2
     3190029191     1104938105              0
     5038989029      744021732              2
     8189289493      400645100              0


Conclusion


We show only a few examples here of possible key patterns. For a data structure to be practical it must support all possible key patterns. Therefore, a hashing data structure would need to have the ability to handle hash function indexing collisions.