Iurii Tatishchev 01d2d7f2cf
8.14 Lab*: BT <--- BST ADT (Park)
- Modify the Park class from previous assignments.
- Rewrite the private insert as a recursive function.
- Write the buildBST() function (similar to buildList() in the doubly-linked list lab).
- Display the number of nodes in the tree as shown below:

- Display the tree in inorder, preorder or postorder
- Display the tree as an indented list
- Display the inner nodes of the BST (including its root), in alphabetical order by code

- Write the searchManager() function (similar to searchManager() in the doubly-linked list lab). It calls search BST in a loop.
- Search the BST (implement the recursive private search function).
2024-05-03 17:08:04 -07:00

89 lines
1.9 KiB
C++

// Specification file for the Park class
// Written By: Iurii Tatishchev
// Reviewed by: Iurii Tatishchev
// IDE: CLion
#ifndef PARK_H
#define PARK_H
// #include<iostream>
#include<string>
// #include<cstdlib>
// using namespace std;
// ^^^^^ This statement
// in a header file of a complex project could create
// namespace management problems for the entire project
// (such as name collisions).
// Do not write using namespace at the top level in a header file!
using std::string;
class Park {
private:
string code; // the unique park identifier
string state;
string name;
string description;
int year;
public:
// constructors
Park();
Park(string, string, string, string, int);
// setters
void setCode(string cd) { code = cd; }
void setState(string st) { state = st; }
void setName(string nm) { name = nm; }
void setDesc(int dsc) { description = dsc; }
void setYear(int yr) { year = yr; }
// getters
string getCode() const { return code; }
string getState() const { return state; }
string getName() const { return name; }
string getDesc() const { return description; }
int getYear() const { return year; }
/* overloaded operators
- the stream insertion operator ( << )
- the relational operators (<, >, == )
*/
friend std::ostream &operator<<(std::ostream &out, const Park &park);
bool operator<(const Park &park) const { return code < park.code; }
bool operator>(const Park &park) const { return code > park.code; }
bool operator==(const Park &park) const { return code == park.code; }
// friend functions
friend void hDisplay(const Park &);
friend void vDisplay(const Park &);
friend void iDisplay(const Park &item, int level);
friend void kDisplay(const Park &item);
};
void hDisplay(const Park &);
void vDisplay(const Park &);
void iDisplay(const Park &item, int level);
void kDisplay(const Park &item);
#endif