构造的二叉树同上:https://blog.csdn.net/weixin_51995229/article/details/124173365?spm=1001.2014.3001.5501
public BTNode find(char x) {
return find(root, x);
}
private BTNode find(BTNode t, char x) {
BTNode p;
if (t == null)//递归出口
return null;
if ((char) t.data == x)//找到了
return t;
else {
//找该结点左子树
p = find(t.lchild, x);
if (p != null)
return p;
//左子树没找到的话,找右子树
p = find(t.rchild, x);
if (p != null)
return p;
else
return null;
}
}