Written homework #5

Due 10/9/2009

1) Solve the recurrence equations listed below:

                T(n) = 32T(n/4) + n^2

                T(n) = 7T(n/3) + n

                T(n) = T(n-2) + n^3

2) Assume that you have a seven-slot hash table (the slots are numbered 0 through 6).  Show the final hash table that would result if you used the hash function h(k) = k mod 7 and linear probing on this list of numbers: 3, 12, 9, 2.  After inserting the key with value 2, list for each empty slot the probability that it will be the next one filled.

3) Do problems 5.1, 5.8

4) Design a data structure for the storage of a collection of n items which uses O(S + n)  memory (for whatever S the user chooses) and achieves on average:

                O(1) time 'insertion', O(1) time 'find'  when n <= S, and

                O(log n - log S) 'insertion', O(log n - log S) 'find' when n > S.

5) Design a comparison based sorting algorithm to sort 5 items using as few comparisons as possible in the worst case.