ComputerScienceExpert

(11)

$18/per page/

About ComputerScienceExpert

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Applied Sciences,Calculus See all
Applied Sciences,Calculus,Chemistry,Computer Science,Environmental science,Information Systems,Science Hide all
Teaching Since: Apr 2017
Last Sign in: 9 Weeks Ago, 5 Days Ago
Questions Answered: 4870
Tutorials Posted: 4863

Education

  • MBA IT, Mater in Science and Technology
    Devry
    Jul-1996 - Jul-2000

Experience

  • Professor
    Devry University
    Mar-2010 - Oct-2016

Category > Programming Posted 23 May 2017 My Price 8.00

Class BinarySearchTree (in bst.h)

I only have 7.50 in my acct sorry, i still hope someone can help me

C++ only 

Program use following : bst.h

Class BinarySearchTree (in bst.h)

Add a public member function int size(): no parameter, int return type. Returns the # of nodes in the calling tree object

Add a public member function T findMin(): no parameter, T return type. Return the smallest value in the calling tree object. This function must be implemented without recursion.

(updated on Tue 7/19) Add a public member function bool contains(const& T value const T& value): one parameter of T type, bool return type. Returns true if value exists in the calling tree object, otherwise return false. This function must be implemented without recursion.

If you need to define additional member functions to help with the above three, make them private.

You are not allowed to modify the given BinarySearchTree code in other ways.

You are not allowed to modify the given Node class.

Do not use any STL container classes.

Main Method

Declare and create a Binary Search Tree object.

Loop to create 20 random numbers in range [1, 100] and insert them into the Binary Search Tree in order of their creation. Use rand() (Links to an external site.) for random number generation.

Display a message "20 random numbers generated.".

Call the newly added size() function and report. Be aware that the result may be less than 20 since Binary Search Tree will automatically remove duplicates

Report the smallest value in the tree by calling the newly added findMin() function.

Ask user for a int and conduct a search using the newly added contains() function.

Finally call member function print() to display the Binary Search Tree in in-order.

See example below for desired output.

Include: system("PAUSE"); after your output to pause the screen.

Ensure you include ALL files (.h, .cpp, and .exe) required to make your program compile and run. I would like to see your .cpp file and the .exe file that is inside your debug directory.
Example output of your program (Bold,Italic indicates user input)

Run 1:

20 random numbers generated.
# of nodes in tree: 20
smallest value is: 13

Enter an int to search for: 45
Not found in this tree

To verify above results, our tree is (in order):
13 28 29 30 35 41 43 44 57 58 64 69 72 75 77 81 84 87 90 100

Run 2:

20 random numbers generated.
# of nodes in tree: 19
smallest value is: 2

Enter an int to search for: 70
Found in this tree

To verify above results, our tree is (in order):
2 10 12 13 16 17 23 33 47 57 65 67 69 70 71 81 90 92 95

Answers

(11)
Status NEW Posted 23 May 2017 08:05 AM My Price 8.00

-----------

Not Rated(0)