previous | start | next

Example 2

        N=10 keys, M=5 chains; Load Factor = 2; good hash function

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

        But we now suppose the hash function is "good". 

        For example, suppose the keys are uniformly distributed so that all
        chains have length 2.


        Then 

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

        The average chain length is 2, and

        For a successful find

        key            probes
        1-st             1
        2nd              2
        3rd              1
        4th              2
        5th              1
        6th              2
        ...              ...
        9th              1
        10th             2
        ------          -----
        total           15

        Average #probes for successful find = 15/10 = 1.5

     


previous | start | next