Homework 3

Due Date: Oct 17, 2014

This assignment is to implement splay tree algorithms in python and to test run them against regular binary search tree algorithms. Two files, BST.py and SplayTree.py, are provided as a starting point.

Start by perusing the file BST.py to get an idea of how the binary search tree algorithms are implemented. You'll find that I tried to stay as close to CLRS as possible. Here are some points worthy of note:

In addition to implementing the CLRS binary search tree algorithms, the file BST.py also contains a print routine for displaying binary search trees sideway for debugging purpose. It also contains testing code in main() so that you can simply run the script BST.py to test the binary search tree algorithms.

Your job is to do the following.

  1. Fill in all the missing code for five methods in the file SplayTree.py. These methods are
  2. Write a test file test.py to compare the running time of binary search tree algorithms against splay tree algorithms. You should design test data in such a way that it demonstrates superiority of splay trees algorithms over regular binary search tree algorithms.
  3. Write a report in README.txt file summarizing your findings. Do your test results agree with theory? If not, explain the discrepancy.
Note the following.

Submit the completed SplayTree.py, test.py, and a README.txt file by zipping them up and emailing the zipped file to me.