Advertisement
Guest User

Untitled

a guest
Feb 24th, 2020
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. #pragma once
  2. class BinaryTreeList
  3. {
  4. private:
  5. struct TreeNode {
  6. int value; //hold the data value
  7. TreeNode* left; //pointer to the left child node
  8. TreeNode* right; //pointer to the right child node
  9. };
  10. TreeNode* root; //pointer to the head node or the root of the tree
  11.  
  12. //define private member functions
  13. void displayInOrder(TreeNode*);
  14. void displayPreOrder(TreeNode*);
  15. void displayPostOrder(TreeNode*);
  16.  
  17. void insert(TreeNode*&, TreeNode*&);//parameters are a reference to a pointer to a TreeNode
  18.  
  19. //private delete node
  20. void deleteNode(int, TreeNode*&);
  21. //private make deletion
  22. void makeDeletion(TreeNode*&);
  23.  
  24. public:
  25. BinaryTreeList();//constructor
  26. ~BinaryTreeList();//destructor
  27.  
  28. //define the operations of a BinaryTreeList
  29. void insertNode(int);
  30. //method to search the tree
  31. bool searchTree(int);
  32.  
  33. //method to remove node
  34. void remove(int);
  35.  
  36. void displayInorder() { displayInOrder(root); }
  37. void displayPreorder() { displayPreOrder(root); }
  38. void displayPostorder() { displayPostOrder(root); }
  39.  
  40. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement