Fix null issue
parent
15eaf59503
commit
6a2a5948fb
|
@ -71,12 +71,14 @@ namespace blt {
|
|||
return nullptr;
|
||||
// check for left and right tree traversal if it exists
|
||||
if (searchNode->left != nullptr && element < searchNode->left->payload) {
|
||||
*parent = searchNode;
|
||||
if (parent != nullptr)
|
||||
*parent = searchNode;
|
||||
searchNode = searchNode->left;
|
||||
continue;
|
||||
}
|
||||
if (searchNode->right != nullptr && element > searchNode->right->payload) {
|
||||
*parent = searchNode;
|
||||
if (parent != nullptr)
|
||||
*parent = searchNode;
|
||||
searchNode = searchNode->right;
|
||||
continue;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue