|
|
|
CSC 2200 |
Lab preparation (at home) Goal Implement the following modifications to Lab #6. The key type for this BST implementation is an integer. Traversal functions and deleteKey function will be added as member functions to the BinTree class. struct BinNode { The specification of BinNode is the same as in Lab #6, but the key is an integer. class BinTree { void printTree() const; void preorderTrasversal() const; private: The preorderTraversal function should check if the tree is not empty. Then it starts traversing the tree from the root using preorder traversal. When a node is visited, the value stored in key is printed on the screen. The inorderTraversal function should check if the tree is not empty. Then it starts traversing the tree from the root using inorder traversal. When a node is visited, the value stored in key is printed on the screen. The postorderTraversal function should check if the tree is not empty. Then it starts traversing the tree from the root using postorder traversal. When a node is visited, the value stored in key is printed on the screen. The deleteKey function should search for the node with key equal to n. If the node is found, it is removed from the tree. The BST property of the tree must be preserved. If needed, you may add auxiliary private member functions.
Finish the implementation and test it. |
|