Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma once
- class BinaryTreeList
- {
- private:
- struct TreeNode {
- int value; //hold the data value
- TreeNode* left; //pointer to the left child node
- TreeNode* right; //pointer to the right child node
- };
- TreeNode* root; //pointer to the head node or the root of the tree
- //define private member functions
- void displayInOrder(TreeNode*);
- void displayPreOrder(TreeNode*);
- void displayPostOrder(TreeNode*);
- void insert(TreeNode*&, TreeNode*&);//parameters are a reference to a pointer to a TreeNode
- //private delete node
- void deleteNode(int, TreeNode*&);
- //private make deletion
- void makeDeletion(TreeNode*&);
- public:
- BinaryTreeList();//constructor
- ~BinaryTreeList();//destructor
- //define the operations of a BinaryTreeList
- void insertNode(int);
- //method to search the tree
- bool searchTree(int);
- //method to remove node
- void remove(int);
- void displayInorder() { displayInOrder(root); }
- void displayPreorder() { displayPreOrder(root); }
- void displayPostorder() { displayPostOrder(root); }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement