mirror of
https://github.com/autistic-symposium/master-algorithms-py.git
synced 2025-05-02 14:56:27 -04:00
Update bst_is_balanced.py
This commit is contained in:
parent
f7dc8af9c4
commit
39922339a3
1 changed files with 2 additions and 2 deletions
|
@ -5,7 +5,7 @@
|
|||
|
||||
def height(root):
|
||||
|
||||
if not root:
|
||||
if root is None:
|
||||
return -1
|
||||
|
||||
return 1 + max(height(root.left), height(root.right))
|
||||
|
@ -13,7 +13,7 @@ def height(root):
|
|||
|
||||
def is_balanced(root):
|
||||
|
||||
if not root:
|
||||
if root is None:
|
||||
return True
|
||||
|
||||
return abs(height(root.left) - height(root.right)) < 2 and \
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue