Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Explain the different types of marketing strategies.

Answered: 1 week ago

Question

Explain product positioning.

Answered: 1 week ago

Question

Explain Industrial market segment.

Answered: 1 week ago

Question

=+2 Why are international employment standards important to IHRM?

Answered: 1 week ago