Question
The Movie Node Struct looks like this struct MovieNode{ int quantity; string title; int ranking; Node* left = NULL; Node* right = NULL; }; Delete
The Movie Node Struct looks like this
struct MovieNode{ int quantity;
string title;
int ranking; Node* left = NULL; Node* right = NULL; };
Delete a movie: deleteMovie(std::string title)
Your code needs to search the tree for that movie node, remove it from the tree, re-assign pointers to bypass the removed node, and free the memory used by the node. If the node to be deleted has both left and right children, replace the deleted node with the node with the minimum value in its right subtree. If the movie is not found in the search process, print Movie not found. and do not attempt to delete.
Be sure to test your program for movie nodes with 0 children, 1 child, or 2
children!
In c++ please, and remember that the struct doesnt have a parent function so if you copy from another unrelated problem you will get a dislike. Thanks
Copy your MovieTree::deleteMovie) function into the box below, with the provided prototype. You may use any helper functions as needed, but they must be copied into the answer box. Your answer should look like: void MovieTree::deleteMovie(std::string title) // Your code here For example Test Test deleting from a tree with no elements Result GRADER] Deleting: Elephant Movie not found. [GRADER] Printing movie inventory Test deleting the root of a two-item tree with [GRADER] Adding: Argo an item on the right. GRADER] Adding: Elephant [GRADER] Printing movie inventory Movie: Argo 3 Movie: Elephant 10 GRADER] Deleting: Argo [GRADER] Printing movie inventory Movie: Elephant 10 Copy your MovieTree::deleteMovie) function into the box below, with the provided prototype. You may use any helper functions as needed, but they must be copied into the answer box. Your answer should look like: void MovieTree::deleteMovie(std::string title) // Your code here For example Test Test deleting from a tree with no elements Result GRADER] Deleting: Elephant Movie not found. [GRADER] Printing movie inventory Test deleting the root of a two-item tree with [GRADER] Adding: Argo an item on the right. GRADER] Adding: Elephant [GRADER] Printing movie inventory Movie: Argo 3 Movie: Elephant 10 GRADER] Deleting: Argo [GRADER] Printing movie inventory Movie: Elephant 10
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