previous | start | next

Deletions

Deletions from a hash table with separate chaining are straightforward.

Open addressing is trickier. Consider deleting key 17020 from this hash table and then lookup 14920:

        hash(14913) = 14913 % 7 = 3
        hash(15930) = 15930 % 7 = 5
        hash(16918) = 16918 % 7 = 6
        hash(17020) = 17020 % 7 = 3
        hash(14920) = 14920 % 7 = 3
        -----------
        0 (14920, 40)
        1 null
        2 null
        3 (14913, 20) 
        4 null        (17020, 19) deleted
        5 (15930, 10)
        6 (16918, 50)

        Pairs in blue are not in their hashed
        positions.

        To lookup 14920, we look for 14920 at positions  3, 4, ... until found
        or until a null entry is encountered.

        It appears that 14920 is not in the table. But it is. 
        What is the problem?
        What is the solution?
        
     


previous | start | next