Problem 1: Suppose the following keys are to be stored in a hash table. ripken, murray, palmer, weaver, robinson, thompson. Let the hash function be ((value(key[0]) + value(key[key.length - 1]) * key.length) % tableSize where key.length gives the length of a key, key[i] gives the character at the ith position of a key, and value(ch) returns the numeric value of the given letter (a = 1, b = 2, etc).
0 null 1 -> palmer -> weaver 2 null 3 -> ripken 4 -> murray -> robinson 5 null 6 -> thompson
0 1 palmer 2 weaver 3 ripken 4 murray 5 robinson 6 thompson
0 robinson 1 palmer 2 weaver 3 ripken 4 murray 5 6 thompson
Problem 2: Consider the following ASCII art heap.
3
/ \
5 10
/ \ / \
8 6 15 12
/ \ / \ / \ /
9 14 7 13 20 16 19
3
/ \
5 4
/ \ / \
8 6 15 10
/ \ / \ / \ / \
9 14 7 13 20 16 19 12
/
21
5
/ \
6 10
/ \ / \
8 7 15 12
/ \ / \ / \ /
9 14 21 13 20 16 19