Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- template<typename T>
- void BinaryTree<T>::push(T data, Node<T>* branch)
- {
- if (root == nullptr)
- {
- root = new Node<T>(data);
- branch = root;
- }
- if (!branch)
- {
- branch = new Node<T>(data);
- }
- else
- {
- if (branch->data < data)
- branch->pLeft = push(data, branch->pLeft);
- if (branch->data > data)
- branch->pRight = push(data, branch->pRight);
- }
- size++;
- }
- template<typename T>
- void BinaryTree<T>::add(T data)
- {
- Node<T>* branch = this->root;
- push(data, branch);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement