Fix search infinite loop on not foundo

v1
Brett 2023-01-10 22:30:54 -05:00
parent 0926d7cc00
commit 15eaf59503
1 changed files with 2 additions and 0 deletions

View File

@ -67,6 +67,8 @@ namespace blt {
while (true) {
if (searchNode->payload == element)
return searchNode;
if (searchNode->left == nullptr && searchNode->right == nullptr)
return nullptr;
// check for left and right tree traversal if it exists
if (searchNode->left != nullptr && element < searchNode->left->payload) {
*parent = searchNode;