Question: C++ Please Help I need help just writing these couple functions. Heres what I have so far for my .h file class BinaryTree { private:

C++

Please Help

I need help just writing these couple functions.

C++ Please Help I need help just writing these couple functions. Heres

Heres what I have so far for my .h file

class BinaryTree

{

private:

struct TreeNode

{

T value; // The value in the node

TreeNode *left; // Pointer to left child node

TreeNode *right; // Pointer to right child node

string name;

int numOfPattiesEaten

};

TreeNode *root;

//Private Member Functions

void insert(TreeNode*&, TreeNode*&);

void destroySubTree(TreeNode*);

void deleteNode(string n, TreeNode*&);

void makeDeletion(TreeNode*&);

void displayInOrder(TreeNode*) const;

void getTotal(TreeNode *nodePtr, int &total);

void getMost(TreeNode *nodePtr, string& n, int& mostPatties);

void getLeast(TreeNide *nodePtr, string& n, int& leastPatties);

public:

BinaryTree()

{

root = NULL;

}

~BinaryTree()

{

destroySubTree(root);

}

void remove(string);

void insertNode(string, int);

bool searchNode(string);

void displayInOrder() const

{

displayInOrder(root);

}

getLeastNumPatties(string, int);

getMostNumPatties(string, int);

getTotalNumPatties();

};

5 Find the lowest number of Krabby Patties eaten by any customer (requires two functions) The public function (getLeastNumPatties) accepts two arguments- a string that will eventually hold the customer's name that has the least number of eaten Krabby Patties and an integer that will eventually hold the customer's # of eaten Krabby Patties. This function sets the integer parameter (leastPatties) to the root node's # of patties and then calls the private function (getLeast) The getleast function is a recursive function that traverses the nodes like the displaylnOrder function except instead of printing out the customer's name, it will check to see if the current node has a smaller number then the one saved in the leastPatties variable. If so, then save this node's customer name & number of patties as the new least. a. b. 6. Find the highest number of Krabby Patties eaten by any customer (requires two functions) a. Follow the instructions for finding the lowest except find the highest instead 7. Find the total number of Krabby Patties eaten by AL customers (requires two functions) The public function (getTotalNumPatties) accepts no arguments. It reates a variable to hold the total and then calls the private getTotal function, sending the root node & the total variable (send total by reference) to the function. Then, this function will return the total as an integer. The getTotal function is a recursive function that traverses the tree like the displaylnOrder function except instead of printing out the customer's name, it will get a running total of Krabby Patties eaten from each node. a. b. 5 Find the lowest number of Krabby Patties eaten by any customer (requires two functions) The public function (getLeastNumPatties) accepts two arguments- a string that will eventually hold the customer's name that has the least number of eaten Krabby Patties and an integer that will eventually hold the customer's # of eaten Krabby Patties. This function sets the integer parameter (leastPatties) to the root node's # of patties and then calls the private function (getLeast) The getleast function is a recursive function that traverses the nodes like the displaylnOrder function except instead of printing out the customer's name, it will check to see if the current node has a smaller number then the one saved in the leastPatties variable. If so, then save this node's customer name & number of patties as the new least. a. b. 6. Find the highest number of Krabby Patties eaten by any customer (requires two functions) a. Follow the instructions for finding the lowest except find the highest instead 7. Find the total number of Krabby Patties eaten by AL customers (requires two functions) The public function (getTotalNumPatties) accepts no arguments. It reates a variable to hold the total and then calls the private getTotal function, sending the root node & the total variable (send total by reference) to the function. Then, this function will return the total as an integer. The getTotal function is a recursive function that traverses the tree like the displaylnOrder function except instead of printing out the customer's name, it will get a running total of Krabby Patties eaten from each node. a. b

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!