avltree/AVLTree.py
def _check_balanced(self, root):
        """checks if the tree is balanced

        Args:
            root (AVLNode): the root of the tree

        Returns:
            bool
        """
        if not root:
            return True

        lheight = self._height(root.left)
        rheight = self._height(root.right)

        lcheck = self._check_balanced(root.left)
        rcheck = self._check_balanced(root.right)
        currcheck = abs(lheight - rheight) < 2
        return lcheck and rcheck and currcheck
checks if the tree is balanced

        Args:
            root (AVLNode): the root of the tree

        Returns:
            bool
        
checks if the tree is balanced
checks if the tree is balanced
def _check_balanced(self, root):
        if not root:
            return True
        lheight = self._height(root.left)
        rheight = self._height(root.right)
        lcheck = self._check_balanced(root.left)
        rcheck = self._check_balanced(root.right)
        currcheck = abs(lheight - rheight) < 2
        return lcheck and rcheck and currcheck
def _check_balanced ( self , root ) : if not root : return True lheight = self . _height ( root . left ) rheight = self . _height ( root . right ) lcheck = self . _check_balanced ( root . left ) rcheck = self . _check_balanced ( root . right ) currcheck = abs ( lheight - rheight ) < 2 return lcheck and rcheck and currcheck
checks if the tree is balanced
checks if the tree is balanced
"""checks if the tree is balanced

        Args:
            root (AVLNode): the root of the tree

        Returns:
            bool
        """
None
self
root
the root of the tree
the root of the tree