Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 13e4d3e

Browse files
Rosepetal2022MaximSmolskiy
andauthored
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>
1 parent c666db3 commit 13e4d3e

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

‎data_structures/binary_tree/avl_tree.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,10 @@ def del_node(root: MyNode, data: Any) -> MyNode | None:
221221
else:
222222
root.set_right(del_node(right_child, data))
223223

224+
# Re-fetch left_child and right_child references
225+
left_child = root.get_left()
226+
right_child = root.get_right()
227+
224228
if get_height(right_child) - get_height(left_child) == 2:
225229
assert right_child is not None
226230
if get_height(right_child.get_right()) > get_height(right_child.get_left()):

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /