CSci 160 Lab 6: A Tale of Two Trees (and one Hash Table)

Objectives

The goal behind this lab is to do some experiments to see first-hand some differences in the performance of binary search trees, AVL trees, and closed hash tables.

Exercises

  1. Start by downloading the following files: Put them all in the same BlueJ project.
  2. In each of these classes, add an instance variable for "counting the number of steps for an insertion." This means different things for the different structures: Also add a public method for returning the number of steps (call it "getSteps()") in each of the above classes. The purpose of the method is to return the number of steps taken just after an insertion has been performed.
  3. Note that the main methods do a whole lot of insertions and removals. Let's make it simpler: They should just do a whole bunch of insertions (determined by the constant NUMS). Delete/modify the existing code accordingly. Also add code to the main methods so that after all the insertions are made, the total number of steps (in all the insertions) is printed out. Finally, make it so that NUMS acquires its value via a command-line argument, so you can try out different values each time you run the code.
  4. Let's put these search structures through their paces. Run all the programs on 10-15 values of NUMS. Start at (say) 10000 and working your way up to 100000 (in steps of 10000), or skip some steps and get up to larger NUMS such as 180000 or 200000.
  5. Observe (and record) the numbers that come out. Graph the numbers as a function of NUMS (that value we usually call "N"!). How would you interpret these graphs? Are they consistent with what we know about these data structures?
Hand in: Electronic copies of the modified programs, with changes clearly indicated with comments. Also hand in written answers to the above questions, and clearly annotated graphs of the points (on the same graph for comparison).
Last modified: 10/25/10 by Frederic Green.