Advertisement
MaksNew

срака собака

Mar 9th, 2021
242
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. template<typename T>
  2. void BinaryTree<T>::push(T data, Node<T>* branch)
  3. {
  4. if (root == nullptr)
  5. {
  6. root = new Node<T>(data);
  7. branch = root;
  8. }
  9. if (!branch)
  10. {
  11. branch = new Node<T>(data);
  12. }
  13. else
  14. {
  15.  
  16. if (branch->data < data)
  17. branch->pLeft = push(data, branch->pLeft);
  18. if (branch->data > data)
  19. branch->pRight = push(data, branch->pRight);
  20.  
  21. }
  22. size++;
  23. }
  24.  
  25. template<typename T>
  26. void BinaryTree<T>::add(T data)
  27. {
  28. Node<T>* branch = this->root;
  29. push(data, branch);
  30. }
  31.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement