fix(avl): be more explicit in is_correct

Signed-off-by: Matej Focko <mfocko@redhat.com>
This commit is contained in:
Matej Focko 2022-05-07 15:38:17 +02:00
parent 93ac86366b
commit 6bde21f85c
Signed by: mfocko
GPG key ID: 7C47D46246790496

6
avl.py
View file

@ -29,7 +29,11 @@ class AVLTree(RankedTree[T]):
if not node: if not node:
return True return True
if not (-1 <= _balance_factor(node) <= 1): if not (
-1 <= _balance_factor(node) <= 1
and node.rank
== 1 + max(Node.get_rank(node.left), Node.get_rank(node.right))
):
return False return False
return not recursive or ( return not recursive or (