diff --git a/trees/README.md b/trees/README.md index 29fd54a..c0ee24f 100644 --- a/trees/README.md +++ b/trees/README.md @@ -39,6 +39,26 @@ def height(root):
+--- + +#### find if balanced + +
+ +```python +def is_balanced(root): + + if not root: + return True + + return abs(height(root.left) - height(root.right)) < 2 and \ + is_balanced(root.left) and is_balanced(root.right) +``` + +
+ +--- + #### predecessor and successor