CSC365 Quiz 1

Rules: Open book. Answer on 8.5X11 paper. 20pts/question.

  1. Suppose you have a java.util.Map, and would like to split its contents evenly into two other Maps. It doesn't matter exactly which elements go in which. If there are an odd number, it doesn't matter which one gets the remainder. Write a method that does this:
    void split(Map source, Map dest1, Map dest2) {

    // write me! }

  2. Show (graphically) the 2-3-4 tree obtained by inserting
    T H E Q U I C K B R O W N F X J U
    
  3. Show the tree in the previous question after deletion of
    F H J K N
    
  4. Show the red-black tree corresponding to the 2-3-4 tree in the previous question (i.e., after deletion.)

  5. Suppose you have a special version of a BinaryTreeMap that only holds Integer keys, and would like to support a method range() that reports the difference between the maximum and minimum keys. Write this method:
    Integer range() {
       if (root == null) return null;
       // finish me!
    }
    

Doug Lea
Last modified: Thu Aug 27 19:08:14 EDT 1998