I'm making a BST & AVL tree working on string keys. In the main , I've not added the "600" key but on finding it shows "600" found.
I tried debugging using gdb & found out that on 2 unequal strings == gave a true value passed my if clause.
I also tried using compare() function of string class, still the same problem.
Please help!
This is my findNode function:
template
NodeType* Tree::findNode(string key, NodeType* node)
{
if ( node == NULL )
return NULL;
else if ( node->Key() == key )
return node;
else if ( key < node->Key() )
findNode(key, node->Left());
else if ( key > node->Key() )
findNode(key, node->Right());
else
return NULL;
}
Here is the link to all of the code https://github.com/tshrjn/ADSA/blob/master/bst.cpp