Question: After completing this assignment you will be able to implement a binary search tree (BST). Name the program for this assignment bst_driver.cpp. In this assignment
After completing this assignment you will be able to implement a binary search tree (BST). Name the program for this assignment "bst_driver.cpp." In this assignment you will make several modifications to the BST class in the file bst.cpp that I provided. Consider the following: 1. Change the declaration of treenode to class treenode //node in a BST { public: string county_name; double population_size; treenode *lchild, *rchild; //left and right children pointers }; 2. Make the following changes to the BST class: a) change the name from BST to bst; b) change default constructor from BST to bst; c) leave empty as is; d) leave insert as is; e) change name of insert_aux to insert; f) change name del to del_name; g) change name of del_aux to del_name with a different signature than f above; h) leave search_tree as is; i) change name of search_tree_aux to search_tree; j) leave inorder_succ as is; k) leave print_tree as is; l) change name of print_tree_aux to print_tree. m) leave private area (the state) as is; n) consider the following class declaration: class bst { public: bst (); //store the data file (county_data.txt) into initial bst ~bst();//de-allocates dynamic memory allocate for tree bool empty(); // checks to see if the tree is empty void insert(const string & item, const double & population); //inserts a county record into bst based on //county_name. void insert(treenode * &, string item); //see insert description above void del_name(string item); //deletes a county record based on county name. void del_name(treenode * & loc_ptr, string item); //see del description above treenode * search_tree(treenode *,string item);//returns pointer to node with county name treenode * search_tree(string item); //see search_tree description above treenode * inorder_succ(treenode *);//return pointer to inorder successor (based on county name. void county_ranges(const string min_name, const string & max_name); //prints all county names //to the screen between min_name and max_name, inclusive. void print_tree( );//prints each county record to the screen sorted by county name. void sorted_info( );//prints each county record to a file called county_info.txt sorted by county //name. private: treenode *root; }; 3. Notes on implementation of county_ranges, sorted_info, and del_name are as follows: a. The void member function county_ranges that accepts two values that represents a name range and prints all the counties with a names in the range, inclusive. Consider the following prototype and function call: Prototype: void population_ranges(const double& min_name, const double & max_name); Function Call: county_ranges(bay, flager); b. The void member function sorted_info that has no formal parameters. This function will print the county information (name and population) to the file county_info.txt. Consider the following prototype that goes inside the class declaration: void sorted_info( ); c. void del_name(string item) deletes a county record based on county name. This function is called from main. Remember the tree is sorted (based) on county name d. void del_name(treenode * & loc_ptr, string item) is an auxiliary function to help delete a county record based on county name. It is a member function that can only be called by another member of the class. All the data for this program is stored in the file county_data.txt. The county name is listed first, followed by the population size. Separate the class declaration and implementation files. Call the header (declaration) for the bst, bst.h and the implementation file, bst.cpp. Call the driver, bst_driver.cpp. Please submit your files in a zip file called module11.zip before the due date and time. Please start early, and let me know if you have any questions.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
