CMPT
225 Lab - Tree Traversals and Searches
This lab is intended to give you some practice
implementing binary search tree traversals and searches
Preliminaries
Copy and paste the code provided in the links
at the end of this document into the a .cpp
file containing your main method and BST
.h and .cpp files. Compile and run the program to make sure you've set
everything up correctly - it should print Pre Order, In Order, Post Order and
the results of ten searches all of which fail. It does not print data or find
values stored in the tree because you are to implement the three traversal
algorithms and the search algorithm.
Traversals
Implement each of the three traversal methods,
printing all of the contents of the tree on one line with spaces between the
values.
The print statement for one value would look
like this:
cout << nd->data <<
" ";
Search
Implement the
search method (it should look familiar to the binary search algorithm).
Program
Files
The files for the main program and the BST class are provided below.
John Edgar (johnwill@sfu.ca)