#判断一棵树是否为完全二叉树
def isCBT(root):
if not root:
return True
isLeaf = False
queue = []
queue.append(root)
while queue:
root = queue.pop(0)
left = root.left
right = root.right
if (not left and right) or (isLeaf and (left or right)):
二叉树问题---判断一棵树是否为完全二叉树
最新推荐文章于 2022-09-02 22:37:06 发布