We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent ed1900f commit 2d2c6d9Copy full SHA for 2d2c6d9
data_structures/binary_tree/avl_tree.py
@@ -215,12 +215,15 @@ def del_node(root: MyNode, data: Any) -> MyNode | None:
215
return root
216
else:
217
root.set_left(del_node(left_child, data))
218
- # root.get_data() < data
219
elif right_child is None:
220
221
222
root.set_right(del_node(right_child, data))
223
+ # Re-fetch left_child and right_child references
224
+ left_child = root.get_left()
225
+ right_child = root.get_right()
226
+
227
if get_height(right_child) - get_height(left_child) == 2:
228
assert right_child is not None
229
if get_height(right_child.get_right()) > get_height(right_child.get_left()):
0 commit comments