0% found this document useful (0 votes)
25 views1 page

Assignment 10

Uploaded by

anhhh.23itb
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views1 page

Assignment 10

Uploaded by

anhhh.23itb
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Assignment 10 – Hashing

Problem 1. Consider hash table of size 10 and hash function h(x) = x%10. Insert the
keys 17, 12, 26, 42, 23, 18, 22, 9, 16, 35 and 15 into the table using linear probing.

Problem 2. Consider a hash table of size 11, and suppose nonnegative integer key
values are hashed into the table using the following hash function:

int h(int key) {


int x = (key + 7) * (key + 7);
x = x / 16;
x = x + key;
x = x % 11;
return x;
}
a. Suppose that collisions are resolved by using linear probing.
b. Suppose that collisions are resolved by using quadratic probing, with the probe
function (k2 + k ) / 2.

Problem 3. Consider a hash table of size 5 and a hash function h(x) = x%5, insert the
keys 2, 7, 6, 12, 23, 11, 22, 19, 1, 3, 5, 32, 4,9 and 15 into the table using separate
chaining for collision resolution.

You might also like