//Here is the function of inserting nodes.I tried using strcmp but its still not working.
void BinarySearchTree::insert(char* d)
{
tree_node* t = new tree_node;
tree_node* parent;
strcpy(t->data,d);
t->left = NULL;
t->right = NULL;
parent = NULL;
// is this a new tree?
if(isEmpty()) root = t;
else
{
//Note: ALL insertions are as leaf nodes
tree_node* curr;
curr = root;
// Find the Node's parent
while(curr)
{
cout<<"current"<<curr->data<<endl;
parent = curr;
if(strcmp(t->data,curr->data)==0)
{
cout<<"duplicat nodes";
exit(1);
}
if(strcmp(t->data,curr->data)>0) curr = curr->right;
else curr = curr->left;
}
if(strcmp(t->data,parent->data)<0)
parent->left = t;
else
parent->right = t;
}
count++;
}