CMPS 340 Fall 2008
HW #4: Extendible Hashing
Due: 12noon, Tuesday, November 25

Suppose that we are using an extendible hash table with bucket size 3 and suppose that our hash function H is such that

H(ANT)  = 01110...  H(BEAR) = 11000...  H(BUG)  = 00011...  H(CAT)  = 01101...
H(COW)  = 00010...  H(DOG)  = 01010...  H(DUCK) = 00110...  H(ELK)  = 10001...
H(GORN) = 00011...  H(LION) = 11000...  H(PIG)  = 00001...  H(RAT)  = 00101...
H(WOLF) = 11101...  H(YAK)  = 01000...

The hash table is as follows:

       Directory

         +----+                   +-----+-----+-----+
(000)  0 |  *-+--->-------------->| COW | PIG | BUG | (000)
         +----+                   +-----+-----+-----+
(001)  1 |  *-+--->-------------->+-----+-----+-----+
         +----+                   | RAT |     |     | (001) 
(010)  2 |  *-+--->-+             +-----+-----+-----+
         +----+      \            +-----+-----+-----+
(011)  3 |  *-+--->---+---------->| DOG | CAT | ANT | (01)
         +----+                   +-----+-----+-----+
(100)  4 |  *-+--->-+
         +----+      \            +-----+-----+-----+
(101)  5 |  *-+--->---+---------->| ELK |     |     | (10)
         +----+                   +-----+-----+-----+
(110)  6 |  *-+--->-+                  
         +----+      \            +------+------+------+
(111)  7 |  *-+--->---+---------->| LION | BEAR | WOLF | (11)
         +----+                   +------+------+------+ 

To the right of each bucket is shown its label (or signature), which describes those cells in the directory that point to it: namely, any cell having an address whose binary representation has the label as a prefix.

For each of the following operations, apply it to the hash table above (not to the result of applying the previous operations) and show the hash table that results. (It suffices to show the portion of the table that has changed, plus a little surrounding context. If the directory is doubled or halved, show its new state.) If a deletion results in two "sibling" buckets having a total number items equal to the capacity of one bucket, then merge the two buckets. (In real life, we probably would not do that, because it would result in a bucket likely to be split in the near future.)

      (a)  Insert DUCK.              (b)  Insert YAK.
      (c)  Delete BEAR.              (d)  Delete BUG. 
      (e)  Insert GORN.              (f)  Delete ANT.