Question: Can someone tell me why my delete function isnt deleting anything? The test results are at the bottom, and they show that my code doesn't

Can someone tell me why my delete function isnt deleting anything? The test results are at the bottom, and they show that my code doesn't actually delete the node from the tree. If you have any edits to the code please write them thanks. C++

MovieNode * getMinValueHelper(MovieNode* node)

{

MovieNode* temp = node;

while (temp->leftChild != NULL){

temp = temp->leftChild;

}

return temp;

}

MovieNode *searcherHelper(MovieNode *node, string title)

{

if(node == NULL){

return NULL;

}

else

{

if(node -> title > title){

if(node -> leftChild == NULL){

return nullptr;

}

return searcherHelper(node -> leftChild, title);

}

else if(node -> title

if(node -> rightChild == NULL){

return nullptr;

}

return searcherHelper(node -> rightChild, title);

}

else {

return node;

}

}

}

MovieNode* deleteNode(MovieNode* node, int quantity)

{

if (node == NULL){

return node;

}

if (quantity quantity){

node->leftChild = deleteNode(node->leftChild, quantity);

}

else if (quantity > node->quantity){

node->rightChild = deleteNode(node->rightChild, quantity);

}

else{

if (node->leftChild == NULL) {

MovieNode *temp = node->rightChild;

free(node);

return temp;

}

else if (node->rightChild == NULL) {

MovieNode *temp = node->leftChild;

free(node);

return temp;

}

MovieNode* temp = getMinValueHelper(node->rightChild);

node->quantity = temp->quantity;

node->rightChild = deleteNode(node->rightChild, temp->quantity);

}

return node;

}

void MovieTree::deleteMovie(string title){

MovieNode* temp = searcherHelper(root, title);

if(temp != NULL){

deleteNode(searcherHelper(root, title), searcherHelper(root, title)->quantity);

}

else{

cout

}

}

Can someone tell me why my delete function isnt deleting anything? The

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!