Fix null issue
parent
15eaf59503
commit
6a2a5948fb
|
@ -71,11 +71,13 @@ namespace blt {
|
||||||
return 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) {
|
||||||
|
if (parent != nullptr)
|
||||||
*parent = searchNode;
|
*parent = searchNode;
|
||||||
searchNode = searchNode->left;
|
searchNode = searchNode->left;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (searchNode->right != nullptr && element > searchNode->right->payload) {
|
if (searchNode->right != nullptr && element > searchNode->right->payload) {
|
||||||
|
if (parent != nullptr)
|
||||||
*parent = searchNode;
|
*parent = searchNode;
|
||||||
searchNode = searchNode->right;
|
searchNode = searchNode->right;
|
||||||
continue;
|
continue;
|
||||||
|
|
Loading…
Reference in New Issue