imrpoved del_node func (13)

This commit is contained in:
Shaurya Bisht 2024-10-13 11:35:17 +00:00
parent bb85f44341
commit e949959eff

View File

@ -201,7 +201,7 @@ def get_balance(node: MyNode | None) -> int:
return get_height(node.get_left()) - get_height(node.get_right())
def get_min_value_node(node: MyNode) -> MyNode:
def get_min_value_node(node: MyNode | None) -> MyNode | None:
if node is None:
return None
current_node = node
@ -209,7 +209,6 @@ def get_min_value_node(node: MyNode) -> MyNode:
current_node = current_node.get_left()
return current_node
def del_node(root: MyNode | None, data: Any) -> MyNode | None:
if root is None:
print("Nothing to delete")
@ -370,4 +369,4 @@ if __name__ == "__main__":
random.shuffle(lst)
for i in lst:
t.del_node(i)
print(str(t))
print(str(t))