Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion data_structures/binary_tree/avl_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,12 +215,15 @@ def del_node(root: MyNode, data: Any) -> MyNode | None:
return root
else:
root.set_left(del_node(left_child, data))
# root.get_data() < data
elif right_child is None:
return root
else:
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:
assert right_child is not None
if get_height(right_child.get_right()) > get_height(right_child.get_left()):
Expand Down