Question: In this exam, you are going to create a C++ class of binary search tree (BST) that holds integer values. Methods should be implemented: BST();

In this exam, you are going to create a C++ class of binary search tree (BST) that holds integer values. Methods should be implemented: BST(); (constructor) -BST(); (destructor) bool insert( int value ); bool search( int value ); void inOrderTraversal(); int depth(); Details: BST() The constructor should initialize an empty BST. -BST() The destructor should delete any dynamic data allocated by the class. bool insert( int value ); This method inserts the value passed into the tree. If there is an error (i.e. creating a tree node fails), the method should return false. If the value is inserted, the method should return true. bool search( int value ); This method should search for the value passed in the tree. If the value is found, the method should return true, else it should return false. void inOrderTraversal(); This method traversals the tree in inorder and prints the values of corresponding nodes. int depth(); This method should compute and return how many levels this tree has. If the tree is empty, zero should be returned. Other methods or classes are not required but are not prohibited either. You should also write a test program to demonstrate that you correctly implement those methods.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!