Professional Documents
Culture Documents
ADS Assignment
ADS Assignment
Q1] Draw the 11-item hash table resulting from hashing the keys 12, 44, 13, 88, 23, 94, 11, 39, 20, 16, and 5,
Ü
using the hash function h(i)=(2 i+ 5) mod 11 and assuming collisions are handled by chaining
l õ ÿR i
Q2] j What is the result of the previous exercise, assuming collisions are handled by linear probing?
Q3] Show the result of Q1, assuming collisions are handled by quadratic probing, up to the point where the
g
collisions, assuming we also use the trick of replacing deleted items with a special “deactivated item” object.
2. Set counter j = 0
4. If hashtable[h[k]] is empty or Deactivated item -> Insert key k at hashtable[h[k]] -> Stop
Else - The key space at hashtable[h[k]] is occupied, so we need to find the next available key space –
h[k] = ( k + j * j ) % SIZE
6. Stop