(Latest Revision: 05/08/2002)

Working With Trees: Extending the Binary Search Tree Class


PRELIMINARIES:

Before starting this assignment you need to be familiar with queues and binary search trees. You also need to be familiar with the directions and examples here: http://www.cs.csustan.edu/~john/Classes/General_Info/progAsgRules/


THE ASSIGNMENT:


IMPLEMENTATIONS:

Keep in mind that it your responsibility is to write the driver and to fill in certain function bodies in the BST2.cpp file. On the other hand, you must not make any "unauthorized" changes to BST2.cpp. Also, you must not change any of the other *.h or *.cpp files I am giving you in the assignment directory.

Make recTreeCount, recTreeHeight, and recRevOrderPrint recursive functions. Implement TreeCount simply by making a single call to its recursive counterpart recTreeCount. Implement TreeHeight and RevOrderPrint similarly with calls to their recursive counterparts recTreeHeight and recRevOrderPrint. In class we will discuss details of the algorithms to be used by recTreeCount, recTreeHeight, and recRevOrderPrint.

For LevOrderPrint, I recommend a solution that employs a queue as an auxiliary data structure. I have given you copies of the files QueueP.h and QueueP.cpp. These files implement a queue data structure that you can use in your LevOrderPrint function. All the include statements necessary are already in place. You will be able declare and use a local variable of type queueClass within your LevOrderPrint function. Also you will be able to declare and use local variables of type treeRef. The treeRef data type is the data type that we place into the queue. A treeRef is a struct with two fields: a pointer that points to a node N in a binary search tree T, and an integer that represents the level of N within T. In class we will discuss more details concerning these data types and also we will discuss the algorithm to be used by the LevOrderPrint function.


COMPILING

The program you are writing will consist of several files. If your driver is named driver.cpp then the program will consist of all these files: driver.cpp, BST2.h, BST2.cpp, Data.h, Data.cpp, QueueP.h, and QueueP.cpp. To compile the program you should use the command:

g++ driver.cpp BST2.cpp Data.cpp QueueP.cpp
alternatively if you are working within a directory where the only files with the .cpp extension are the ones mentioned above then the following enormously simpler command will work:

g++ *.cpp
This is one reason why it is a good idea to work on each new program in a new directory.


WHAT TO TURN IN:

You will turn in two sets of hardcopies and you will send two e-mail messages.

With regard to the e-mail please follow these rules: Here is a list of the things you have to turn in:
  1. On the morning of the first due date , turn in a hardcopy of your completed driver code.
  2. Send me an e-mail copy of your completed driver code before midnight on the first due date. Send it by e-mail with the subject line: CS2500,prog5.drv.

  3. On the morning of the second due date , turn in a hardcopy of your completed driver code, and a hard copy containing the code for the new functions of BST2.cpp that you implemented. DO NOT turn in any of the other parts of BST2.cpp -- that file is too long and we don't want to waste the paper.
  4. Send the following items to me by e-mail before midnight on the second due date:

    In your e-mail send me all header and source files (all *.h files and *.cpp files) that are required to compile the program into an executable image -- everything I need to compile the program. Combine all the source files and the script into one shell archive file and e-mail me the archive file with the subject line: CS2500,prog5.fin.

Note that there are no spaces in the subject lines given. It is important that you do not insert any spaces. My e-mail address is: john@ishi.csustan.edu.


DUE DATES:

For the due dates, see the class schedule.