next up previous


CSE 2320 Section 501 Fall 1998

Homework 3

Due: October 27, 1998, in class (October 28, 1998, 5:00pm for -10%)

1.
Show the final hash tables described below after inserting the keys 4, 18, 13, 51, 11, 24, 1, 15, 26 in this order. Show all computations of hash table indices, including collisions.

(a)
A hash table with m=13 slots using collision resolution by chaining and the division method hash function $h(k) = k \bmod m$.

(b)
A hash table with m=13 slots using open addressing and the linear probing hash function $h(k,i) = (h^{\prime}(k) + i) \bmod m$, where $h^{\prime}(k) = k \bmod m$.

(c)
A hash table with m=13 slots using open addressing and the quadratic probing hash function $h(k,i) = (h^{\prime}(k) + i + i^2) \bmod
m$, where $h^{\prime}(k) = k \bmod m$.

(d)
A hash table with m=13 slots using open addressing and the double hashing function $h(k,i) = (h_1(k) + i h_2(k)) \bmod m$, where $h_1(k) = k
\bmod m$ and $h_2(k) = 1 + (k \bmod (m - 1))$.

(e)
Compare the number of collisions made by each hash function above.

(f)
Does the quadratic probing hash function of part c make full use of the hash table? Justify your answer.

2.
Show the binary search tree whose postorder traversal is 1, 2, 3, 4, 6, 10, 9, 8, 7, 5. Also, show the preorder traversal of the tree.

3.
Show the Red-Black trees that result after each successive insertion of the keys 3, 7, 12, 9, 1, 15, 8, 5, 13, 4 (in this order) into an initially empty Red-Black tree.

4.
Show the Red-Black trees that result after each successive deletion of the keys 7, 6, 1, 10, 9, 12, 2, 11, 5, 4, 3, 8 (in this order) from the following Red-Black tree.


\begin{figure}
\centerline{\psfig{figure=figures/h33.ps}}
\end{figure}

5.
Show the B-trees that result after each successive insertion of the keys X, K, N, R, U, V, Y, C, D, J, S, Z, G, H, A, M, E, B, L, F, I, T (in this order) into an initially empty B-tree with minimum degree t = 3.

6.
Show the B-trees that result after each successive deletion of the keys 13, 19, 16, 4, 2, 22, 1, 14, 20, 17, 8, 21, 11 (in this order) from the following B-tree with minimum degree t = 2. When you have a choice between a left or right sibling, always choose the left sibling. Always try Case 2a (predecessor) before Case 2b (successor).


\begin{figure}
\centerline{\psfig{figure=figures/h35.ps}}
\end{figure}


next up previous