判断满二叉树
public class Node{
int value;
Node left;
Node right;
}
int deep(Node root){
if(root==null){
return 0;
}
int leftDepth = deep(root.left);
int rightDepth = deep(root.right);
return rightDepth>leftDepth?rightDepth+1:leftDepth+1;
}
bool isFullBinTree(Node root){
if(root==null){
return false;
}
if(root.left==null&&root.right==null){
return true;
}
int leftDepth = deep(root.left);
int rightDepth = deep(root.right);
if(leftDepth!=rightDepth){
return false;
}
if(isFullBinTree(root.left)&&isFullBinTree(root.right)){
return true;
}else{
return false;
}
}
标签:Node,判断,return,int,deep,right,二叉树,java,root
来源: https://www.cnblogs.com/shijianchuzhenzhi/p/12984187.html