Tree: Depth-First Search - Balanced Binary Tree
Examine this code snippet for checking if a binary tree is balanced:
def is_balanced(root):
def height(node):
if node is None:
return 0
left_height = height(node.left)
right_height = height(node.right)
if abs(left_height - right_height) > 1:
return -1
return max(left_height, right_height) + 1
return height(root) != -1
Which issue could cause incorrect results on trees with null nodes?