mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-02-06 17:40:55 +00:00
Fix error in avl_tree del_node function (#11510)
* fixed error in del_node function * Update avl_tree.py --------- Co-authored-by: Maxim Smolskiy <mithridatus@mail.ru>
This commit is contained in:
parent
c666db3729
commit
13e4d3e76c
|
@ -221,6 +221,10 @@ def del_node(root: MyNode, data: Any) -> MyNode | None:
|
||||||
else:
|
else:
|
||||||
root.set_right(del_node(right_child, data))
|
root.set_right(del_node(right_child, data))
|
||||||
|
|
||||||
|
# Re-fetch left_child and right_child references
|
||||||
|
left_child = root.get_left()
|
||||||
|
right_child = root.get_right()
|
||||||
|
|
||||||
if get_height(right_child) - get_height(left_child) == 2:
|
if get_height(right_child) - get_height(left_child) == 2:
|
||||||
assert right_child is not None
|
assert right_child is not None
|
||||||
if get_height(right_child.get_right()) > get_height(right_child.get_left()):
|
if get_height(right_child.get_right()) > get_height(right_child.get_left()):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user