Answers for "When we insert a new node in a binary search tree, it will be added as a"

0

insert binary search tree

void BSNode::insert(std::string value) {

	if (this->_data == value) {
		_count++;
		return;
	}

	if (this->_data > value) {
		if (this->getLeft() == nullptr) {
			this->_left = new BSNode(value);
		}
		this->getLeft()->insert(value);
		return;
	}

	if (this->getRight() == nullptr) {
		this->_right = new BSNode(value);
		return;
	}
	this->getRight()->insert(value);
}
Posted by: Guest on January-03-2021

Code answers related to "When we insert a new node in a binary search tree, it will be added as a"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language