Fix search infinite loop on not foundo
parent
0926d7cc00
commit
15eaf59503
|
@ -67,6 +67,8 @@ namespace blt {
|
||||||
while (true) {
|
while (true) {
|
||||||
if (searchNode->payload == element)
|
if (searchNode->payload == element)
|
||||||
return searchNode;
|
return searchNode;
|
||||||
|
if (searchNode->left == nullptr && searchNode->right == nullptr)
|
||||||
|
return nullptr;
|
||||||
// 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->left->payload) {
|
||||||
*parent = searchNode;
|
*parent = searchNode;
|
||||||
|
|
Loading…
Reference in New Issue