Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bool BinarySearchTree::insert(DataType val)
- {
- if (root_==NULL)
- {
- root_=new Node(val);
- size_++;
- root_->left=NULL;
- root_->right=NULL;
- return true;
- }
- else
- {
- Node*current=root_;
- //current node will keep track of where we are
- if ((current->val)>val)
- {
- current=current->left;
- insert(val);
- }
- else if ((root_->val)<val)
- {
- current=current->right;
- insert(val);
- }
- else if(current->val==val)
- {
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement