Question
Write a program that uses the binary tree definition in Figure 6.8 on page 220-222 1. Add a function to the class to count the
Write a program that uses the binary tree definition in Figure 6.8 on page 220-222 1. Add a function to the class to count the number of nodes in a binary tree 2. Add a function to the class to count the number of leaves in a binary tree YOU MUST USE THE BINARY TREE DEFINITION AS LISTED IN THE BOOK. Any other tree definition will not be accepted. Create a program that uses this class as follows (The tree is used store strings names)
1. The program should present the user with a menu as follows:
1. Add a new name 2. Delete a name 3. List the contents in ascending order 4. Display the number of nodes in the tree 5. Display the number of leafs 6. Exit the system Please enter your choice 2. Create a function for each option on the menu to handle the request. 3. For choice # 1 (Add a new value), the function should prompt the user to enter a value (a string). If the value is already stored in the tree, you should display a message that indicates that. 4. For choice # 2 (Delete a value), the function should prompt the user to enter a value (a string). Display a message to indicate if the value is found and deleted or if it is not found. 5. Main() should call a function called menu() to display the menu and return users input. Main() should not handle any input or output other than reading and validating users input.
220 Chapter 6 Binary Trees FIGURE 6.8 mplementation of a generic binary search tree. //***genBST.h ** generic binary search tree #include #include queue>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