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;

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

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!