Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ Homework help. Please help with averageRating() and queryMovies() functions. These functions are on the last page. The class and struct definition is provided. The

C++ Homework help.

Please help with averageRating() and queryMovies() functions. These functions are on the last page. The class and struct definition is provided. The assignment is here just to give you a reference for context. Will rate from multiple accounts! Thanks in advance.

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

Here is the def. of movie tree (movietree.hpp):

#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; };

Background In 2009, Netflix held a competition to see who could best predict user ratings for films based on previous ratings without any other information about the users or films. The grand prize of US$1,000,000 was given to the BellKor's Pragmatic Chaos team which bested Netflix's own algorithm for predicting ratings by 10.06%. This kind of data science is facilitated with the application of good data structures. In fact, cleaning and arranging data in a conducive manner is half the battle in making successful predictions. Imagine you are attempting to predict user ratings given a dataset of IMDB's top 100 movies. Building a binary search tree will enable you to search for movies and extract their features very efficiently. The movies will be accessed by their titles, but they will also store the following features IMDB ranking (1-100) Title e Year released IMDB average rating Your binary search tree will utilize the following struct with default and overloaded constructors struct MovieNode int ranking; std::string title; int year; float rating; MovieNode *parent nullptr; MovieNode *leftChild nullptr; MovieNode *rightChild-nullptr; MovieNode) fh MovieNode(int r, std::string t, int y, float q): ranking(r), title(t), year(y), rating(q) t) l; Movie Cl Your code should implement a binary search tree of movies. A header file that lays out this tree can be found in Movie Tree.hpp on Moodle. As usual, do not modify the header file. You may implement helper functions in your.cpp file to facilitate recursion if you want as long as you don't add those functions to the Movie Tree class MovieTree0) Constructor initialize any member variables of the class to default -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(0 Print every node in the tree in alphabetical order of titles using the following format Ifor every Movie node (m) in the tree cout Add a node to the tree in the correct place based on its title. Every node's left children should come before it alphabetically, and every node's right children should come after it alphabetically. Hint: you can compare strings with ,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 title year ,,,,,, Add a node to the tree in the correct place based on its title. Every node's left children should come before it alphabetically, and every node's right children should come after it alphabetically. Hint: you can compare strings with ,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 title year ,,,,,,

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

1 2 3 Data Base Techniques

Authors: Dick Andersen

1st Edition

0880223464, 978-0880223461

More Books

Students also viewed these Databases questions