Homework 12
The purpose of this assignment is to understand the Data Structure
of a Binary Search Tree and the Binary Search algorithm. For this assignment
you will be given the BinarySearchTree class definition, main, and a
random assortment of words. Main will read and input each word from a
file and insert the word into the tree according to the BST's properties.
Main is a menu based program that will prompt the user to insert, search,
remove, and display the tree. Your task is to complete the definitions
for the following recursive Binary Search Tree Operations:
- void deallocateSubtree(TreeNode<T> *) - this function
will recursively traverse in post order and deallocate each TreeNode
within the Binary Search Tree
- bool insertSubtree(TreeNode<T> *&, T) - this function
will recursively traverse the Binary Search Tree and insert the passed
element to it's corresponding placement according to the properties of
the Binary Search Tree
- bool deleteSubtree(TreeNode<T> *&, T) - this function
will recursively traverse until the passed elemnent is found,
find the in-order successor to replace the found node, patch
the TreeNode links, then deallocate the found node
- bool searchSubtree(TreeNode<T> *, T) - this function
will recursively traverse in pre order and search for the passed
parameter. If the element is found, return true, otherwise recursively
search left and right. If the element it never found, return false
- void displayInOrderSubtree(TreeNode<T> *T) - this function
will recursively traverse the BST in order (LVR) and print the
data of each TreeNode
- void displayPreOrderSubtree(TreeNode<T> *T) - this function
will recursively traverse the BST in pre order (VLR) and print the
data of each TreeNode
- void displayPostOrderSubtree(TreeNode<T> *T) - this function
will recursively traverse the BST in pre order (LRV) and print the
data of each TreeNode
pseudocode will be given in lecture.
Directory:
hw12 dir
Files:
main.cpp
BinarySearchTree.h
BinarySearchTree.cpp
words.txt
Have your completed source code and all files associated with this
assignment within your ~/2020_S19/wk12/ directory.