问题描述
- 这段代码输出的root是root->data==item的那个root吗,不是的话是哪个root
-
//查找二叉树中值为item的结点
BTNode *FindBTree(BTNode *root, DataType item)
{
if (root != NULL)
{
FindBTree(root->left, item);
FindBTree(root->right, item);
if (root->data == item)
{
return root;
}
}
}
解决方案
新人求带,感觉好复杂的样子,好吧我努力
解决方案二:
返回的是最后找到item的root,除非return在if语句外面做最终返回才是原来的root。
解决方案三:
因为递归是一个压栈的过程,我想只要你能够深入的理解递归的过程(函数压栈)的话,我觉得你肯定知道结果...
解决方案四:
是,不过是最后一次找到的那个root(如果有多个的话),
解决方案五:
Android中Root权限获取的简单代码(3)
时间: 2024-08-30 02:15:31