Assignment 4
Due: 9 Nov 2011
Educational objectives:
- Primary objectives: Implement a simple self-restructuring binary search tree.
- Secondary objectives: Implement and use templates, develop test cases to test the correctness of your software, empirically compare the performance of different data structures.
Statement of work: Implement a generic self-restructuring binary search tree class, using a self-restructuring scheme specified below.
Deliverables:
- Turn in a
makefile
and all header (*.h) and cpp (*.cpp) files that are needed to build your software, as described in www.cs.fsu.edu/~asriniva/courses/DS11/HWinstructions.html. Turn in your development log too, which should be a plain ASCII text file calledLOG.txt
in your project directory.Requirements:
- Create a subdirectory called
proj4
.- You will need to have a
makefile
in this directory. In addition, all the header and cpp files needed to build your software must be present here, as well as theLOG.txt
file.- You should create the following additional files.
- MRBST.h: This should implement a generic
MRBST
class. This class is a self-restructuring binary search tree. It restructures by rotating a node with its right child, if the node is found by thesearch
operation, and if the right child exists. (We are assuming that if a node is found, then it is less likely to be searched for in the near future.) You should implement at least the following features: (i)void push(const T &)
, (ii)bool search(const T &)
, (iii)void PrintPreorder()
, (iv) a default constructor without arguments, and (v) a destructor. Thepush
function inserts a node into the tree. Thesearch
function returnstrue
if and only if its argument is present in the tree, and also causes a restructuring operation to be performed. ThePrintPreorder
function prints the values stored in each node, using a pre-order traversal.- test.cpp: This is a code that you write to check whether your tree works correctly. Note that we will not provide a sample executable for this assignment. You should create suitable test cases and test your code thoroughly.
- compare.cpp: This program will be compiled to create an executable called
compare-containers
, and the executable will be run as follows.This code should store all the words in the dictionary available in
./compare-containers Filename
, whereFilename
is the name of a file containing words separated by whitespaces. Each word contains a string of lower case letters.~cop4530/fall11/solutions/proj4/words
on linprog in three different containers: (i) MRBST, (ii) STLlist
, and (iii) STLset
. (We will copy this directory to the current working directory before running your program; you should do the same.) It will then check if each word inFilename
is present in the standard dictionary using each of the three containers. It will also determine the time taken by each container to check each word and output each result, mentioning the word, container and time taken. For example:
aim, MRBST, 0.001 seconds
aim, list, 0.01 seconds
aim, set, 0.001 seconds
zebra, MRBST, 0.01 seconds
zebra, list, 0.02 seconds
zebra, set, 0.01 seconds
aim, MRBST, 0.002 seconds
aim, list, 0.01 seconds
aim, set, 0.001 seconds
- result.txt: This is an ASCII text file. It should first describe how you tested your
MRBST
code. It should then discuss the relative performance of MRBST against that of the STLlist
andset
. For example, under what situation is one data structure better than the other in terms of search time. Justify your conclusions with timing results. If the MRBST had rotated searched words one level up, then would its performance have been better for this application?Note:
- We will test your
MDBST
class with code that is different from yourtest.cpp
. So it is important for this class to be generic and exactly as specified.Bonus points (5):
You may get up to 5 additional points for significant extra work, such as providing a GUI interface. Please obtain feedback from us prior to doing this. If you wish to get bonus points, then please submit your work as usual, but send an email to the TA with a cc to me. The TA will schedule a meeting with you, and you can demonstrate the special features of your software then.
Copyright: Ashok Srinivasan, Florida State University.
Last modified: 24 Oct 2011