previous | start | next

Example (continued)

Inserting the first three pairs (14913, 20), (15930, 10), (16918, 50) we get:

        hash(14913) = 14913 % 7 = 3
        hash(15930) = 15930 % 7 = 5
        hash(16918) = 16918 % 7 = 6

        -----------
        0 null
        1 null
        2 null
        3 (14913, 20)
        4 null
        5 (15930, 10)
        6 (16918, 50)
     

To lookup the quantity for product code 15930, we just apply the hash function again:

        Lookup quantity for 15930: hash(15930) = 15930 % 7 = 5
        At index 5 we get (15930, 10), so the quantity is 10.
     


previous | start | next