Computer Science 241

Data Structures

Project 8

Due at 11:59 P.M. on Monday, December 8

Overview

In this project, you will implement recursive functions to manipulate a binary tree.

Specifications

You have been provided the files tree.h and tree.cc that partially implement a variation of the binary tree class. Your task is to implement and test the missing functions.

The first task for this project is to create a tree from a file.

The remaining functions are grouped in pairs. The public function calls the private function that recursively computes the solution. Each function must use the pointer representation of the tree to compute the answer.

As with all projects, you must write a thorough test program for your implementation of these member functions. Your test program should be contained in the file main.cc and should be documented using the "percent block" comments. The files input0.dat, input1.dat, input2.dat, input3.dat, input4.dat, and input5.dat contain trees for testing.

The Guidelines for Programming Projects apply. You are also subject to the Guidelines for Programming Assignments, issued by the Department of Computer Science as an addendum to The Honor System.

Additional Notes

You may assume that if the file opens, then all data contained in the file is valid. If the file does not open, simply return. You may also assume that no file contains more than TREE_ARRAY_SIZE elements.

Every recursive function can be implemented in 10 lines or less.

You do not need to test functions already contained in the implementation file.

Submit

To submit your files for grading, place all files in the same directory, and at the prompt in that directory enter:

~radu/bin/submit CS241 project8

There will be no late submissions allowed for this project. The last day to submit any class related work is the last official day of classes: Monday, December 8.

Your submission will fail if the project does not compile.

Grading

20 points
treeNode* ArrayToPtr(int i)
10 points each
void ReadTreeAsArray(const char* fname)
int FindNodeCount(treeNode* TreePtr)
treeItemType FindMaxElement(treeNode* TreePtr)
bool FindMember(treeNode* TreePtr, const treeItemType& Target)
int FindHeight(treeNode* TreePtr)
2 points each
tree(const char* fname)
int NodeCount()
treeItemType MaxElement()
bool Member(const treeItemType& Target)
int Height()
10 points each
Test Program
Style

The implementation points cover both correctness and efficiency. It is not enough to turn in a program that compiles and executes. The graders will scrutinize the implementation of the member functions and will deduct points for poor design decisions even if your program runs correctly on all reasonable input.

The style points cover poor programming style that needs to be addressed and a lack of useful comments within your program. In addition, graders may deduct style points for implementations that will work but could lead to difficulties or inefficiencies.

When grading your test program, the graders will look for evidence that you considered the various implementation issues in this class. Even if your code works, you will be penalized for not testing that it works. This also means that you can lose points twice for the same issue: once in the implementation and again for not performing proper testing (which would have identified the first).

Header Files


Valid XHTML 1.0! Valid CSS!