Homework 5
Short Description:
This assignment is worth 15 points.
Goals
When you finish this homework, you should have:
- Have Implemented a Binary Search Tree.
- Had further experience with pointers.
Formal Description
Implement a binary search tree class. Your class should include a
specification file and an implementation file. Your class should
be called bst, and your files should be bst.h and bst.cpp.
Please implement your class to hold strings as a data field.
You should implement the following member functions:
- void Add (string element) insert element into the tree.
- void Kill (string element) delete element from the tree if it is there.
- void InOrder(void) do an inorder print of the tree.
- bool IsPresent(string element) return true if the element is in the tree, if not, the element is not in the tree.
- string Successor(string element) Returns the successor of an element or the empty string.
- string Predecessor(string element) Returns the predecessor of the element, or the empty string.
- string Minimum() returns the minimum value of the tree or the empty string.
- string Maximum() return the maximum value of the tree or the empty string.
- int Height()return the height of the tree.
- int Height(string element) returns the height of the element.
- int Depth(string element) return the depth of the element.
Input
None.
Output
None.
Discussion
I will compile and link your program against my own driver. It better work
with no alterations.
Required Files
The .h, .C files.
Extra Credit
None.
Submission
Email the files to me by November 28 at class time.