使用前序遍历判断
struct Node
{
int _data;
Node* _left;
Node* _right;
Node(const int& x)
: _data(x)
, _left(NULL)
, _right(NULL)
{}
};
bool IsExist(Node* root, Node* point)
{
if (root == NULL)
return false;
if (point->_data == root->_data)
return true;
bool IsInLeft = IsExist(root->_left, point);
if (IsInLeft == true)
return true;
else
return IsExist(root->_right, point);
}