Question
/****************************************************************/ /* MovieTree Definition */ /****************************************************************/ /* LEAVE THIS FILE AS IS! DO NOT MODIFY ANYTHING! =] */ /****************************************************************/ #pragma once #include // MovieNode: node
/****************************************************************/ /* MovieTree Definition */ /****************************************************************/ /* LEAVE THIS FILE AS IS! DO NOT MODIFY ANYTHING! =] */ /****************************************************************/
#pragma once
#include
// MovieNode: node struct that will be stored in the MovieTree BST
struct MovieNode { int ranking; // Rank of the movie std::string title; // Title of the movie int year; // Year this movie was released float rating; // IMDB rating
MovieNode *parent = nullptr; // Pointer to the parent node MovieNode *leftChild = nullptr; // Pointer to the leftchild MovieNode *rightChild = nullptr; // Pointer to the rightChild
// default constructor MovieNode(){} // Parametrized constructor MovieNode(int r, std::string t, int y, float q) : ranking(r), title(t), year(y), rating(q) {} };
// Class for storing and manipulating a tree of MovieNode's class MovieTree { public: // Check writeup for detailed function descriptions MovieTree(); ~MovieTree(); void printMovieInventory(); void addMovieNode(int ranking, std::string title, int year, float rating); void findMovie(std::string title); void queryMovies(float rating, int year); void averageRating(); private: MovieNode *search(std::string title); // Pointer to the root node MovieNode *root; };
Test functions please. I have a second part to this also. Will give thumbs up right away!
No additional helper methods. I have other functions to be implemented, but as far as now I just need to follow the write up as it is.Thanks
-MovieTree0 Destructor: Free all memory that was allocated MovieNode "search(string title) This private function is meant to be a helper function. Return a pointer to the node with the given title, or nullptr if no such movie exists void printMovielnventory) Print every node in the tree in alphabetical order of titles using the following format / for every Movie node (m) in the tree cout ==' string:compare() function etc. You may assume that no two movies have the same title void findMovie(string title) Find the movie with the given title, then print out its information: cout ranking title year rating ==' string:compare() function etc. You may assume that no two movies have the same title void findMovie(string title) Find the movie with the given title, then print out its information: cout ranking title year ratingStep 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