I have the following simple method for doing a complete search of a binary tree. I can definitely tell it can be simplified, but it's not coming to me.
bool Node::lookup(int d)
{
if (data==d)
{
return true;
}
else
{
if (left != NULL && right != NULL)
{
return left->lookup(d) && right->lookup(d);
}
else if (left != NULL)
{
return left->lookup(d);
}
else if (right != NULL)
{
return right->lookup(d);
}
else
{
return false;
}
}
}