Question: / / bintree.h - - - - - - - - - - - - - - - - - - - - - -

// bintree.h---------------------------------------------------------------
// ADT Binary Search Tree using nodes
//----------------------------------------------------------------------------
// Includes all of the common BST functions as well as some aditional functions
// Does not include a remove function
//----------------------------------------------------------------------------
#include //input and output
#include
#include
using namespace std;
const int ARRAYSIZE =100;
// BST Node contains pointer for left, right, and data
struct Node {
string data;
Node *left;
Node *right;
};
class BinTree {
// Overloaded << : prints BinTree in correct structure
friend ostream &operator<<(ostream &, const BinTree &);
public:
// Constructors
BinTree();
BinTree(const BinTree &);
// Desctructor
~BinTree();
// required public methods
bool isEmpty() const; // check if tree is empty
// retrieve the pointer of the node of given data
bool retrieve(const string &, Node *&) const;
bool insert(const string &); // insert node with the node data
// displays the tree in pre-order, provide prefix (Root, L--, R--)
void displayTree() const;
void displaySideways() const; // displays the tree sidways
// get height of a node starting from leaf (=1)
int getHeight(const string &) const;
// Overload operators
//-- Assignment Operator
BinTree &operator=(const BinTree &); // this = rhs
//-- Comparison Operators
bool operator==(const BinTree &) const; // this == rhs
bool operator!=(const BinTree &) const; // this != rhs
// Miscellaneous Functions
void bstreeToArray(string[]);
void arrayToBSTree(string[]);
private:
Node *root; // Points to the root of the BST
// You can add private methods here
};

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!