Question
Write a C++ program using a Class to implement a Binary Search Tree (BST). Clearly define your Class with member functions and private data area.
Write a C++ program using a Class to implement a Binary Search Tree (BST). Clearly define your Class with member functions and private data area. Class private data area must contain the root pointer to the tree you are building. Use the data file named BinarySearchTree.data (located in canvas Files->Assignments->Assignment06) to build your BST and produce the output for following inquiry by calling the member functions and perform the tasks correctly. 1. How many nodes were in your search tree? Example output: "Tree nodes counted. Number of Nodes = 20567" 2. Print the entire tree. 3. What is the smallest element in the tree? 4. What is the largest element in the tree? 5. What is the height of the tree? 6. What is the height of the left sub-tree? 7. What is the height of the right sub-tree? 8. Check an element in the BST? 9. How many nodes are in level "N" of the tree? 10. Print the smallest value in the tree. 11. Print the largest value in the tree. 12. Destroy the tree and put the memory back to the pool. Implement a minimum of the following routines as member functions in your class definition. Enhance your Class as needed by adding member functions. 1. treeIsEmpty() - check for an empty tree. 2. treeInsert() - insert an element into the BST. 3. treeContains() - check an element is in the tree. 4. treeHeight() - print the height of the tree. 6. treeHeightL() - height of the left sub-tree. 7. treeHeightR() - height of the right sub-tree. 8. treeCountNodes() - count the nodes in the tree. 9. treePrint() - print the entire tree. 10. treeFindMin() - find the smallest element value 11. treeFindMax() - find the biggest element. ... ... Programming standards and file name explained in class must be strictly followed. This assignment is an individual project and Individual attempt is required.
Binary Search Tree Data:-5058 -272 2383 218 3015 4903 6470 -2977 -8271 137 -8891 7042 193 6211 6695 -82 -8304 -6856 4616 -5546 8139 9978 -7492 6151 -6293 -9435 -8339 -2890 -4286 -4905 7635 -8164 -9129 1289 -2605 8613 -2569 1947 -6959 5170 8749 -8633 5765 -3040 -8172 -3889 6290 -3559 5217 -5554 8065 -9529 -7321 -4314 4355 -7680 -5406 -4809 1821 -6184 -9506 7268 3228 4781 7226 -1538 9837 -6621 4378 -9203 403 -7655 -4093 -5650 -7749 7767 7779 2951 -700 5104 -4573 6846 7126 -2144 5155 -760 8866 3066 222 -8792 -3318 -6769 -4363 3317 -4977 -5117 4381 -6342 -7538 -3865 2833 5163 3411 1095 -1423 -6917 -4203 1815 -4705 -1768 1944 389 8963 -3187 -1195 6787 6494 -2179 9454 -6839 -2607 -5393 7303 3010 -5536 -7906 -9318 -8161 -8564 4645 3435 5874 -1654 -6867 8747 234 5063 -7250 -8773 -917 -7918 -6225 -797 -5611 -8211 -4788 -6623 6194 -6916 -7733 -5144 248 4899 -3637 4170 9469 3442 -3213 -7284 -7629 8820 2919 -6325 4803 -4263 -9602 -4535 9965 -6814 6472 2012 -805 -3884 -7792 -9630 8711 -4501 6406 4759 8981 8737 -7491 -5464 9088 -3438 6086 -5818 3215 -7968 3355 389 4461 476 -1874 -4840 -5834 -610 -7747 -8849 -4819 -5558 -1711 -7697 -26 1309 -907 2096 8396 8001 -5604
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