Question
I just want to know how to write these functions: void deleteMovieNode(std::string title); MovieNode* search(std::string title); MovieNode* treeMinimum(MovieNode *node); I got these three functions, MovieNode*
I just want to know how to write these functions:
void deleteMovieNode(std::string title);
MovieNode* search(std::string title);
MovieNode* treeMinimum(MovieNode *node);
I got these three functions,
MovieNode* search(std::string title);
MovieNode* treeMinimum(MovieNode *node); they are the helper function I think, and I tried to write these two like this:
MovieNode* search(std::string title)
{
MovieNode *foundMovie = root;
while(founMovie != NULL)
{
if(foundMovie->title > title)
{
foundMovie = foundMovie->leftChild;
}else if(foundMovie->title < title)
{
foundMovie = foundMovie->rightChild;
}
return foundMovie;
}
cout<<" Movie not found."<
return NULL;
}
MovieNode* treeMinimum(MovieNode *node)
{
MovieNode *current = node;
while(current ->lefchild != NULL)
{
current = current->leftChild;
}
return current;
}
But I don't how to use these two to write deleteNode function(ps:if I writed wrong for those two functions,plz help me modify)
one thing I know is that, if i want to use search function;
I can do this:
MovieNode *foundMoive = search(title);
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started