Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a program in C++ to create a Binary Search tree (BST) of integers. The program will perform these operations: Insert node(s), Traverse In-order, Search
Write a program in C++ to create a Binary Search tree (BST) of integers. The program will perform these operations: Insert node(s), Traverse In-order, Search node, Delete node, Leaf Count, Parent of a node and Quit Use the header file similar to this: #include #ifndef BT H #define BTH using namespace std; class BT private: struct node int data; node* left; node* right; l; node* root; public: BT); bool isEmpty) const return rootNULL void insert (int); void print_inorder(); void inorderTrav (node); void searchBST (int) void deleteNode(int) int count(); int leafCount (node*); void nodeParent(int); //Constructor //Check for empty //Insert item in BST //In-order traversing driver //In-order traversing //Searches BST for a specific node //Delete item from BST //Count driver //Counts number of leaves in BST //Finds parent of a node tend if Use the following menu in your program MENU 1.Insert node(s) Traverse In-order Search node Delete node Leaf Count Parent of a node 4 7.Quit Enter your choice Deletes a node from the BST It will prompt: Enter item you want to delete: 30 Option 4: If the item is found then delete the item from the BST and displays the message - "is deleted." If the item is not in the BST, then it will display -"is not found in the BST" 30 is deleted Counts the number of leaves in the BST and displays "There are number of leaves in the BST." Option 5: Enter the item and it will display the Parent of that item. It will prompt: Enter the item you want to find the Parent of: Option 6: The parent of is If the item has no parent then it displays: IS has no parent. Ex Enter the item: 10 The parent of 10 is 20 Option 7: Quit the program
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