
FSU COP 4530 / CGS 5425 (Fall 2005)
Data Structures, Algorithms, and Generic Programming
Due: Dec 5
Assignment 6: Max points: 100
Please show steps or give justifications for all your answers, unless we specify otherwise.
Each question is worth 10 points.
1. Show the order in which nodes are visited in the following traversals of the binary tree shown below: (a) post-
order, and (b) pre-order.
2. Draw the AVL tree that results after the following sequence of operations on a tree that is initially empty:
insert(9), insert(4), insert(2), insert(7), insert(8), insert(3), insert(0), insert(2.5), Delete(2), Delete(0), Delete(3),
Delete(2.5). Show the intermediate trees after each operation, in order to get partial credit for an incorrect answer.
3. Show the heap that results from using the O(n) time max-heap initialization algorithm on the following array:
5 6 9 2 8 1. Show both, pointer and array representations.
4. (a) Show the heap that results from applying the following operations to the heap of #3: push(5), push(9),
push(1). (b) Show the heap that results from applying the following operations to the result of #4a: pop(), pop().
(pop = DeleteMax.)
5. Draw an open addressed hash table of size 7 after the sequence of operations given below. Also give the
number of table entries checked for each of the operations. The following hash function is used:
int hash(string s)
{
int sum=0, I;
for(I=0; I<s.size(); I++)
sum += s[I]-โaโ;
return sum;
}
The probe function is: p(i) = i*i.
1
2
346
7
5
8