// error: expected constructor, destructor, or type conversion before '*' token
*** Error code 1
make: Fatal error: Command failed for target `bst.o'
class BinarySearchTree
{
private:
int count;
int n;
struct tree_node
{
tree_node* left;
tree_node* right;
char data[1000];
};
tree_node* root;
public:
BinarySearchTree()
{
root = NULL;
count = 0;
n=1;
}
bool isEmpty() const { return root==NULL; }
void print_preorder();
void print_format(tree_node*,int,int[100],char) const;
void preorder(tree_node*,int,int[100],char) const;
void insert(char*);
void remove(char*);
bool search(char*);
tree_node* inorderSuccessor(tree_node*); /* Finds the inorder successor of a node */
int num_nodes();
//int countNodes(tree_node *&root);
};
tree_node* BinarySearchTree::inorderSuccessor(tree_node* p )
{
if(!p) return NULL;
p=p->right;
if (!p) return NULL;
while (p->left) {
p= p->left;
}
return p;
}