previous | start | next

Example 1

        N = 10 Keys, M = 5 chains, Load Factor=2; bad hash function

        Here the average chain length is N/M = 2.

        But suppose the hash function is "bad". 

        For example, suppose all the keys end in 0 and the hash function is
        just the key mod 5.  

        Then all keys map to chain 0.

        chain          length
        0              10
        1               0
        2               0
        3               0
        4               0

        The average chain length is λ = 2 and  1 + λ/2 is also 2.

        For a successful find

        key            probes
        1-st             1
        2nd              2
        3rd              3
        ...              ...
        10th             10
        ------          -----
        total                   55

        Average #probes for successful find = 55/10 = 5.5

        Average #probes for an unsuccessful find is 10 (again assuming all
        keys map to chain 0).
     


previous | start | next