mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-04-06 13:55:54 +00:00
imrpoved del_node func (13)
This commit is contained in:
parent
bb85f44341
commit
e949959eff
@ -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))
|
Loading…
x
Reference in New Issue
Block a user