Levels Tought:
Elementary,Middle School,High School,College,University,PHD
Teaching Since: | Apr 2017 |
Last Sign in: | 9 Weeks Ago, 5 Days Ago |
Questions Answered: | 4870 |
Tutorials Posted: | 4863 |
MBA IT, Mater in Science and Technology
Devry
Jul-1996 - Jul-2000
Professor
Devry University
Mar-2010 - Oct-2016
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. Enter an int to search for:Â 45 To verify above results, our tree is (in order): Run 2: 20 random numbers generated. Enter an int to search for:Â 70 To verify above results, our tree is (in order): |