boolean printAllAncestors(BinaryTreeNode root,BinaryTreeNode node){
if(root == null){
return false;
}
if(root.getLeft() == node || root.getRight() == node || printAllAncestors(root.getLeft(),node) ||
printAllAncestors(root.getRight(),node)){
System.out.println(root.getData());
return ture;
}
return false
}
打印二叉树中的某节点的所有祖先节点
猜你喜欢
转载自blog.csdn.net/weixin_37632716/article/details/114680044
今日推荐
周排行