fix(avl): be more explicit in is_correct
Signed-off-by: Matej Focko <mfocko@redhat.com>
This commit is contained in:
parent
93ac86366b
commit
6bde21f85c
1 changed files with 5 additions and 1 deletions
6
avl.py
6
avl.py
|
@ -29,7 +29,11 @@ class AVLTree(RankedTree[T]):
|
|||
if not node:
|
||||
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 not recursive or (
|
||||
|
|
Loading…
Reference in a new issue