
Lab 10: String Binary Search Trees
In this lab, you will write two files: BinStringTree.h that contains some basic
functionality of a binary tree that contains Standard Template Library strings as its
values; and BinStringDriver.cpp which contains the main() function and acts as
the client code. Declare and define a BinStringTree class in BinStringTree.h in
the same format as the last lab's BinTree.h file. That is, for each method written, write
a version of that method that is accessible to the client code in BinStringDriver.cpp,
and a static version that is called by the public method and that performs the actual
manipulations of the tree.
Lab Assignment:
1. Create a constructor that constructs an empty tree.
2. Create the method insert(string) that takes a string value and inserts it into a
new node created in the appropriate position in the tree.
3. Write a method called preorder() that prints the contents of the tree using a
preorder traversal.
4. Write a method called inorder() that prints the contents of the tree using an
inorder traversal.
5. Write a method called find(string) that searches for a matching string in the
tree.
6. Write a method called destroyTree(const Node * ptr), that will be called
by the destructor, ~BinStringTree(), that destroys the entire tree.
Extra credit problem:
7. Write a method called remove(string) that searches for a node with the same
string value as the method's parameter, and removes that node from the tree, while
preserving the search tree property of the remaining nodes.
Turn In:
Upload BinStringTree.h with your name in a comment at the top of the files, and your
BinStringDriver.cpp.