An online movie service needs help keeping track of their stock. You should help them by developing a program that stores the movies in a Binary Search Tree (BST) ordered by the first letter in the movie title, and then a singly linked list for each node in the BST that includes the information for the movie. For each of the moviesin the stores inventory, the following information is kept: IMDB ranking Title Year released Quantity in stockYour program will have a menu similar to previous assignments from which the user could select options. In this assignment, your menu needs to include options for finding a movie, renting a movie, printing the inventory, deleting a movie, and quitting the program.Your program needs to incorporate the following functionality. These are not menu options, see Appendix A for the specific menu options.Insert all the movies in the tree.When the user starts the program they will pass it the name of the text file that contains all movie information. Each line in the file shows the IMDB ranking, title, year released, and quantity in stock. Your program needs tohandle that command line argument, open the file, and read all movie data in the file.From this data, build the BST ordered by the first letter in the movie title. For each of the nodes in the BST, there should be a sorted singly linked list of the actual movie data. Note: the nodes should be added to the BST and Linked Listsin the order they are read in. The name of the file that contains the movie data is Assignment6Movies.txt.Find a movie.When the user selects this option from the menu, they should be prompted for the name of the movie. Your program should then search the tree and singly linked lists and display all information for that movie. If the movie isnot found, your program should display, Movie not found.Rent a movie.When the user selects this option from the menu, they should be prompted for the name of the movie. If the movie is found in your data structure, your program should update the Quantity in stock property of the movie anddisplay the new information about the movie.If the movie is not found, your program should display, Movie not found.When the quantity reaches 0, the movie should be deleted from the singly linked list. If that was the only node in the singly linked list, the node should also be deleted from the BST for that letter.Print the entire inventory.When the user selects this option from the menu, your program should display all movie titles and the quantity available in sorted order by title. See the lecture notes and recitation exercises on in-order tree traversal, andlinked list traversals, for more information.Delete a movie.When the user selects this option, they should be prompted for the title of movie to delete. Your code should then search the tree for the first letter of that movie, and then search the singly linked list for the title. If the title isfound, delete it from the singly linked list. If it was the only title for that letter in the BST, you also need to delete the node in the BST and re-assign the parent and child pointers to bypass the deleted node, and free the memoryassigned to the node. If the movie is not found in the search process, print Movie not found and do not attempt to delete.A movie node should also be deleted when its quantity goes to 0.Count movies in the tree.When the user selects this option, your program should traverse the tree and singly linked lists and count the total movie nodes in the tree and print the count.Quit the program.When the user selects this option, your program should delete the nodes in the tree and exit the program.When the user selects quit, the destructor for the MovieTree class should be called and in the destructor, all of the nodes in the tree and singly linked lists should be deleted. You need to use a postorder tree traversal for the delete or you will get segmentation fault errors.Use the cout statements in Appendix A to set the order of the menu options.Implementation detailsYour BST should be implemented in a class. You are provided with a MovieTree.hpp file on Moodle that includes the class prototype for this assignment. You need to implement the class functionality in a corresponding MovieTree.cpp file Assignment6.cpp file. Do not modify the MovieTree.hpp file. Use the Assignment 6Submit link on Moodle to submit your work. If you do not get your assignment working on Moodle, you will have the option of a grading interview to get back up 50% of the points lost.What does a BST of Linked Lists look likeHeres a diagram to help you visualize the data structure you need to build for this assignment. The BST nodes are marked with individual letters as the key for the node. Each BST node then contains a pointer to a singly linked list for the titles that start with that letter. Titles in the linked list need to be in sorted order, ascending.Appendix A cout statements that CodeRunner expectsDisplay menucout << ======Main Menu====== << endl;cout << 1. Find a movie << endl;cout << 2. Rent a movie << endl;cout << 3. Print the inventory << endl;cout << 4. Delete a movie << endl;cout << 5. Count the movies << endl;cout << 6. Quit << endl;Find a moviecout << Enter title: << endl;Display found movie informationcout << Movie Info: << endl;cout << =========== << endl;cout << Ranking: << foundMovie->ranking << endl;cout << Title: << foundMovie->title << endl;cout << Year: << foundMovie->year << endl;cout << Quantity: << foundMovie->quantity << endl;If movie not foundcout << Movie not found. << endl;Rent a movie//If movie is in stockcout << Movie has been rented. << endl;cout << Movie Info: << endl;cout << =========== << endl;cout << Ranking: << foundMovie->ranking << endl;cout << Title: << foundMovie->title << endl;cout << Year: << foundMovie->year << endl;cout << Quantity: << foundMovie->quantity << endl;//If movie not found in treecout << Movie not found. << endl;Print the inventory//For all movies in treecout<<Movie: <<node->title<< <<node->quantity<<endl;Count movies in the treecout<<Tree contains: <<mt.countMovieNodes()<< movies. << endl;Delete moviecout << Enter title: << endl;//If movie not found in treecout << Movie not found. << endl;Delete all nodes in the tree//For all movies in treecout<<Deleting: <<node->title<<endl;Quitcout << Goodbye! << endl;
CPP
[Solved] Binary Search Trees and Linked Lists
$25
File Name: Binary_Search_Trees_and_Linked_Lists.zip
File Size: 339.12 KB
Only logged in customers who have purchased this product may leave a review.
Reviews
There are no reviews yet.