Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

in C++ code Your ShelterBST class should implement the following functions. However, this time, you will sort your ShelterBST by Pet Name A. Insert a

image text in transcribed
in C++ code
Your ShelterBST class should implement the following functions. However, this time, you will sort your ShelterBST by Pet Name A. Insert a node to ShelterBST This time, you will need to ensure there are no duplicates in your insert function (i.e., the tree should refuse to insert a Pet with a duplicate name). B. Search and InOrder, PreOrder, PostOrder traversals as defined in Lab3. You can reuse this code, but modify it to use Pet name for all comparisons (instead of age). C. Find the parent for a given pet name Your private method should take as input an existing Pet name stored in your tree, and return the TreeNode* that is its ancestor/parent node. Your public method should display the Pet name and age of the parent node. You do not need to consider the situation when the input value is not stored in your BST. Only input the values already stored in your BST. D. Find the successor for a given node with 2 children. You do not need to consider the situation when the input node has one no children. Your private method should take as input an existing Pet name stored in your tree, and return the TreeNode* that is its successor node. Your public method should display the Pet name and age of the successor node. E. Number of nodes in your tree Return the number of total nodes in your BST. The return value should be an integer. F. Find the number of leaf nodes in your tree Return the number of leaf nodes in BST. The return value should be an integer. G. Find the number of nodes at a given level Return the number of nodes at a given in your BST. For example, if your BST is not empty, at level zero there is one node (the root). H. Find the height of the tree Return the height of your BST. The return value should be an integer. I. Balance check Input the root node of this tree. If this BST is balanced, return true; otherwise, return false. J. Delete a node based on a Pet name Delete a node based on the pet name given by the user. After deleting the node, your BST should be reconstructed. If the node to be deleted has two children, reconstruct the tree using the inorder successor (you should use the method you will write for D). You do not need to consider the situation when the input value is not stored in your BST. Only input the values already stored in your BST

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

Privacy In Statistical Databases International Conference Psd 2022 Paris France September 21 23 2022 Proceedings Lncs 13463

Authors: Josep Domingo-Ferrer ,Maryline Laurent

1st Edition

3031139445, 978-3031139444

More Books

Students also viewed these Databases questions

Question

oil mouse cholesterol

Answered: 1 week ago

Question

Evaluating Group Performance?

Answered: 1 week ago