next up previous


CSE 2320 Section 060/061 Spring 1999

Homework 3

Due: March 25, 1999, in class (March 26, 1999, 5:00pm for -10%)

1.
Show each of the final data structures described below after inserting the keys 15, 35, 12, 13, 29, 2, 11, 24, 5 in this order.

(a)
Stack, using an array. Be sure to indicate the top of the stack.

(b)
Queue, using an array. Be sure to indicate the head and tail of the queue.

(c)
Singly-linked list. Be sure to indicate the head of the list.

(d)
Doubly-linked list. Be sure to indicate the head of the list.

(e)
Doubly-linked list with sentinel. Be sure to indicate the sentinel of the list.

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

(g)
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$. Show all computations of hash table indices, including collisions.

(h)
A hash table with m=13 slots using open addressing and the double hashing function $h(k,i) = (h_1(k) + ih_2(k)) \bmod m$, where $h_1(k) = k
\bmod m$ and $h_2(k) = 1 + (k \bmod m^{\prime})$, $m^{\prime} = m-2$. Show all computations of hash table indices, including collisions.

(i)
Binary-search tree. Show the preorder, inorder and postorder traversals of your tree.

2.
Show that the number of different binary-search trees T(n)containing n keys is exponential in n. Hint: derive a recurrence for T(n) and use the substitution method to show $T(n) = \Omega(2^n)$. Show all work.


next up previous