diff --git a/data_structures/binary_tree/avl_tree.py b/data_structures/binary_tree/avl_tree.py index 6056863df..97236ac4d 100644 --- a/data_structures/binary_tree/avl_tree.py +++ b/data_structures/binary_tree/avl_tree.py @@ -227,8 +227,8 @@ def del_node(root: MyNode | None, data: Any) -> MyNode | None: right_child = root.get_right() assert right_child is not None temp = get_min_value_node(right_child) - - root.set_data(temp.get_data()) + if temp is not None: + root.set_data(temp.get_data()) root.set_right(del_node(root.get_right(), temp.get_data())) root.set_height( @@ -370,4 +370,4 @@ if __name__ == "__main__": random.shuffle(lst) for i in lst: t.del_node(i) - print(str(t)) + print(str(t)) \ No newline at end of file