Professional Documents
Culture Documents
Worksheet Hash
Worksheet Hash
Give the contents of the hash table that results when you insert items with the
keys C O M P U T E R in that order into an initially empty table of M = 5 lists,
using separate chaining with unordered lists. Use the hash function 11 k mod M to
transform the kth letter of the alphabet into a table index, e.g., hash(I) = hash(9) =
99 % 5 = 4.
2. Give the contents of the hash table that results when you insert items with the
keys L O C K D O W N in that order into an initially empty table of size M = 16
using linear probing. Use the hash function 11k mod M to transform the kth letter
of the alphabet into a table index.
3.Give the contents of the hash table that results when you insert items with the
keys E A SY QUESTION in that order into an initially empty table of size M = 16
using double hashing. Use the hash function 11k mod M for the inital probe and the
second hash function (k mod 3) + 1 for the search increment.
4. For each of the following collision resolution techniques, insert the keys 17, 3,
19, 39,45 , 56, 28, 100 and 22 into a hash table of size 11 in the order given using
hash function h(x) = x mod 11. Show all of your calculations.
(a) Chaining.
0 1 2 3 4 5 6 7 8 9 10
0 1 2 3 4 5 6 7 8 9 10
(c) Open addressing with double hashing and secondary hash function h2(x) = 1 + (x
mod 8).
0 1 2 3 4 5 6 7 8 9 10