CS507 Data Structures and Analysis of Algorithms


Final Exam - given on April 28, 1998

  1. Give an implementation of a three-way merge sort algorithm, that is an algorithm which splits the input array into three equal (~) parts, sorts each of them and then merges the three sorted subarrays into the original array.
  2. Assume that A is a sorted array of integers, of size n. Implement a variation of binary search which would recursively split the array at the index n/4, rather than at n/2.
  3. What would the be the worst case behavior of your algorithm?

  4. Assume that a hash table with open address hashing would use a probing function defined by
  5. p(k,i)=(h(k)+2i) mod TABLE_SIZE.

    Under what conditions would hashing work correctly?

    What would the incorrect behavior mean in this case? Give an example (e.g. a concrete hash table and a sequence of insertions).