寻找pRoot------>node的一条路径,存在的话保存到list里,最终返回true;否则返回false
bool FindNodePath(BinaryTreeNode *pRoot, BinaryTreeNode *pNode, std::list<BinaryTreeNode *> &path)
{
if (pRoot == pNode)
{
path.push_back(pRoot);
return true;
}
if (pRoot == NULL)
return false;
bool found = false;
found = FindNodePath(pRoot->lchild, pNode, list);
if (!found)
found = FindNodePath(pRoot->rchild, pNode, list);
if (!found)
list.pop_back();
return found;
}