判断为满二td
公共类节点{
int value;
节点左;
节点权限;
}
int deep (节点根) {
if(root==null ) {
返回0;
}
intleftdepth=deep(root.left;
intrightdepth=deep(root.right;
return rightDepthleftDepth? 右深度1:左深度1;
}
boolisfullbintree(noderoot ) {
if (root==空) {
返回假;
}
root.left==null root.right==null ) {
返回真;
}
intleftdepth=deep(root.left;
intrightdepth=deep(root.right;
左移深度!=rightDepth
返回假;
}
is full bintree (root.left ) is full bintree (root.right ) }
返回真;
}else{
返回假;
}
}