Fix insert?

v1
Brett 2023-01-10 22:58:49 -05:00
parent 21aa7ed6ac
commit 33ee1f2dc7
1 changed files with 2 additions and 2 deletions

View File

@ -47,11 +47,11 @@ namespace blt {
if (element == searchNode->payload) if (element == searchNode->payload)
throw binary_search_tree_error{"Unable to insert. Nodes cannot have equal values!\n"}; throw binary_search_tree_error{"Unable to insert. Nodes cannot have equal values!\n"};
// check for left and right tree traversal if it exists // check for left and right tree traversal if it exists
if (searchNode->left != nullptr && element < searchNode->left->payload) { if (searchNode->left != nullptr && element < searchNode->payload) {
searchNode = searchNode->left; searchNode = searchNode->left;
continue; continue;
} }
if (searchNode->right != nullptr && element > searchNode->right->payload) { if (searchNode->right != nullptr && element > searchNode->payload) {
searchNode = searchNode->right; searchNode = searchNode->right;
continue; continue;
} }