Question: binary search tree problem /** * @file CityStateZip.h * * Defines a record containg the city name, * state, and ZIP code for a single

binary search tree problem

binary search tree problem /** * @file CityStateZip.h * * Defines arecord containg the city name, * state, and ZIP code for asingle city. * * @remarks This is a stand-alone header; no implementationfile * is required. */ #ifndef CITYSTATEZIP_H #define CITYSTATEZIP_H #include #include classCityStateZip { public: CityStateZip( std::string city_name, std::string state_name, unsigned int zip_code ): _city{city_name}, _state{state_name}, _zip{zip_code} {} /** * access the city name ** @return city name */ std::string city ( ) const { return

/** * @file CityStateZip.h * * Defines a record containg the city name, * state, and ZIP code for a single city. * * @remarks This is a stand-alone header; no implementation file * is required. */ #ifndef CITYSTATEZIP_H #define CITYSTATEZIP_H #include  #include  class CityStateZip { public: CityStateZip( std::string city_name, std::string state_name, unsigned int zip_code ) : _city{city_name}, _state{state_name}, _zip{zip_code} {} /** * access the city name * * @return city name */ std::string city ( ) const { return _city; } /** * access the state name * * @return state name */ std::string state( ) const { return _state; } /** * access the zip code * * @return zip code */ unsigned int zip ( ) const { return _zip; } /** * writes the city, state and zip to the specified stream in * a standard format * * @param strm the output stream to write to * @return `strm` is returned to allow chaining */ std::ostream& write( std::ostream& strm ) const { return strm   The Binary Search Tree CSZNode Clas A binary search tree is to be constructed for the storage of city names, states, and ZIP code numbers; see Figure 1 for the arrangement of seven CSZNodes (with state and ZIP codes omitted). The objects themselves will be represented by the CityStateZip class defined in the header file "CityStateZip.h" provided as a resource for this assignment. Place a copy of the header file in your project directory and take a moment to look over the functionality of CityStateZip Jonesboro Fort Wayne Madison Charlotte Jacksonville Lubbock San Diego Fig.1 Example of a Binary ACSZNode in a tree differs from a CSZNode in a singly-linked list or stack in that there are two outgoing links. Unlike a doubly-linked list, these links don't move "forward" and "backward", but instead move "down" the hierarchy in the 'left" and 'right directions. Therefore two pointers will be necessary; these pointers are typically referred to as left and right, as these labels reflect the depiction of the pointers in a diagram of the tree. Consider the following class definition for a CSZNode in a binary search tree. Search Tree class CS2Node public: payload(data) CSZNode const CityStatezip& data void void cityStatezip get data const; CSZNode CS2Node set_left CSZNode newleft set_right CS2Node new_right); get left const; get_right( ) const; void write( std::ostream& fout ) const private: CityStatezip payload; CSZNode CS2Node eft nullptr; right = nullptr; std: iostream& operator

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!