Answered step by step
Verified Expert Solution
Question
1 Approved Answer
BINARY TREE OPERATIONS: 1. Insert a new node (requires two functions) The public function (insertNode) should accept a new customer's name and the number of
BINARY TREE OPERATIONS: 1. Insert a new node (requires two functions) The public function (insertNode) should accept a new customer's name and the number of Krabby Patties they ate. This function should create a new TreeNode and fill it with these new values and then call the private function (insert). The insert function (recursive function) inserts the node in the correct position. a. b. 2. Delete a node (requires three functions) a. The public function (remove) accepts a customer's name in order to identify the node that should be removed This function prints, "You are trying to delete [name]." This function will call the private deleteNode function (a recursive function) The deleteNode function tries to find the node that needs deleted. If deleteNode finds the node, it calls the private makeDeletion function. If deleteNode does not find the node, it should print "I'm sorry. That customer can't be found in the Krusty Krab." The makeDeletion function removes the node and reattaches the branches of the tree below the node. b. c. 3. Display names of customers (requires two functions) The public function (displaylnOrder) will call the private overloaded function also called displaylnOrder. The private displaylnOrder accepts a TreeNode as an argument and it is a recursive function which traverses the nodes using the inorder method and prints the customer's name from each node. a. b. 4. Search for a customer The searchNode function accepts the customer's name as an argument and then it will look at each node (traverse the tree) to find the node with that name. If the name is found, the function returns the number of Krabby Patties that customer ate. If not, then it will return -1 instead. a
Step 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