#include "iostream.h"
#include "conio.h"
enum ErrorCode {success,fail,not_present,duplicate_error,underflow,
overflow, range_error};
struct BinaryNode
{
int data;
BinaryNode *left;
BinaryNode *right;
BinaryNode();
BinaryNode(const int &x);
};
BinaryNode::BinaryNode()
{
left=right=NULL;
}
class SearchTree
{
public:
SearchTree();
void inorder(void (*visit)(int &));
ErrorCode insert(const int &new_data);
ErrorCode remove(const int &old_data);
protected:
void recursive_inorder(BinaryNode *sub_root,void (*visit)(int
&),int i);
ErrorCode search_and_insert(BinaryNode *&sub_root,const int
&new_data);
ErrorCode remove_root(BinaryNode *&sub_root);
ErrorCode search_and_destroy(BinaryNode *&sub_root,const int
&target);
BinaryNode *root;
};
SearchTree::SearchTree()
{
root=NULL;
}