Question: I cannot figure this out to save my life! void printMovieInventory() This function should print out every node in the tree, in alphabetical order. It

I cannot figure this out to save my life!

void printMovieInventory() This function should print out every node in the tree, in alphabetical order. It should print in the following format: //For all movies in tree (m)

cout << "Movie: " << m->title << " " << m->quantity << endl;

Hint: You may need to create a helper function.

Your answer should look like:

void MovieTree::printMovieInventory()//HAS TO BE EMPTY { // Your code here }

For example:

Test Result
Test printing an empty inventory. (You should not see any output other than the [GRADER] line.)
[GRADER] Printing movie inventory 
Test printing a tree with a single node.
[GRADER] Adding: Elephant [GRADER] Printing movie inventory Movie: Elephant 10

#ifndef MOVIETREE_HPP #define MOVIETREE_HPP

#include

struct MovieNode { int ranking; std::string title; int year; int quantity;

MovieNode *parent; MovieNode *leftChild; MovieNode *rightChild;

MovieNode(){ parent = leftChild = rightChild = nullptr; }

MovieNode(int r, std::string t, int y, int q) { ranking = r; title = t; year = y; quantity = q; parent = leftChild = rightChild = nullptr; } };

class MovieTree { public: MovieTree(); ~MovieTree(); void printMovieInventory(); void addMovieNode(int ranking, std::string title, int year, int quantity); void findMovie(std::string title); void rentMovie(std::string title); private: MovieNode *search(std::string title); MovieNode *root; };

#endif

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!