首页 > 编程知识 正文

正则二叉树是满二叉树吗,java实现二叉树遍历

时间:2023-05-05 04:25:37 阅读:156096 作者:4133

判断为满二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{

返回假;

}

}

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。