improved del_node func(13)

This commit is contained in:
Shaurya Bisht 2024-10-13 12:22:40 +00:00
parent 4fc0c00b90
commit 9218a96cc7

View File

@ -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))