=========================================================================== CSC 263H Tutorial Outline for Week 8 Winter 2004 =========================================================================== ------------------- Incremental Hashing ------------------- Consider a hash table T used for incremental hashing, initially using b = 4 buckets with modulus m = 4, where chaining is used to resolve collisions. Suppose that T has unused room for 4 more buckets (i.e., the array used to store T has capacity 8), and that we want to keep the load factor a in the range (2,3), i.e., we want 2 <= a <= 3 at all times. (a) What is the hash function used with T for incremental hashing? (b) Suppose that the hash table has the following initial content (unused buckets are blank; remember that m = 4, b = 4): --- -------- -------- -------- -------- 0| o-+->| 8 | o-+->| 44 | o-+->| 24 | o-+->| 36 | / | |---| -------- -------- -------- -------- 1| o-+->| 17 | / | |---| -------- -------- 2| o-+->| 10 | o-+->| 26 | / | |---| -------- -------- -------- 3| o-+->| 19 | o-+->| 3 | o-+->| 39 | / | |---| -------- -------- -------- 4| | |---| 5| | |---| 6| | |---| 7| | --- Perform the following operations on this hash table (include any growth necessary if the load factor gets larger than 3): INSERT(40), INSERT(41), INSERT(42) (c) Perform the following operations on your hash table from part (b): INSERT(33), INSERT(32), INSERT(28) (d) Perform the following operations on your hash table from part (b): DELETE(3), DELETE(40), DELETE(42), DELETE(44) (e) During insertion, what would you do if you needed more than 8 buckets? Would m need to change? Think about the corresponding situation during deletion: for example, what would you do if you had 16 buckets and needed fewer than 4 after performing a deletion? Would m need to change?