Question
THIS IS C++. Create a (partial) BST class and a driver program to test it. The tree node will store integers as the data/key field
THIS IS C++.
Create a (partial) BST class and a driver program to test it. The tree node will store integers as the data/key field (single field). Note that you will need to guarantee there are no duplicates in your insert function (the tree should refuse to insert a dupicate key).
Public methods to include:
* Constructor
* Copy constructor
* overloaded assignement operator
* Destructor
* Insert value ( DO NOT ADD DUPLICATE VALUES)
* Find key -returns bool indicating if value is present in tree
* Find min key - returns min key value
* Find max key - returns max key value
* Find height - returns integers
* Pre-order Traversal done RECURSIVELY (Print key values to screen)
* In- order Traverse done RECURSSIVELY (Print key values to screen)
(Use STL Stack for this)
* Remove key
There may be additional private helper methods as needed, but no printing methods should appear either privately or publicly.
Your driver should insert a minimum of 20 random* values to the tree. Test all the public methods of your class in the driver, printing the results to the screen. Be sure to test the removal in all possible circumstances.
*Random doesn't mean you need to use the random number generator, though you are welcome to do so. But it does mean you do not want to insert values 1 thru 20 (in that order) into your tree. Consequently, you should decide on your values in advance and store them in an array to insert. Include at least one duplicate value to properly test the insert.
Call your files "tree.h", "tree.cpp", and "p3.cpp"
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