forked from UNN/2026-rff_mp
[10] A minor update that fixes errors and typos
This commit is contained in:
parent
49e91066d4
commit
28de33a83d
|
|
@ -221,10 +221,10 @@ def bst_insert(root, name, phone):
|
||||||
return create_node(name, phone)
|
return create_node(name, phone)
|
||||||
|
|
||||||
if name == root['name']:
|
if name == root['name']:
|
||||||
root[phone] = phone
|
root['phone'] = phone
|
||||||
elif name < root['name']:
|
elif name < root['name']:
|
||||||
root['left'] = bst_insert(root['left'], name, phone)
|
root['left'] = bst_insert(root['left'], name, phone)
|
||||||
elif name >= root['name']:
|
else:
|
||||||
root['right'] = bst_insert(root['right'], name , phone)
|
root['right'] = bst_insert(root['right'], name , phone)
|
||||||
return root
|
return root
|
||||||
|
|
||||||
|
|
@ -241,7 +241,7 @@ print("====== END TEST =======\n\n\n")
|
||||||
def bst_find(root, name):
|
def bst_find(root, name):
|
||||||
if root is None:
|
if root is None:
|
||||||
return None
|
return None
|
||||||
if name == root['name']
|
if name == root['name']:
|
||||||
return root['phone']
|
return root['phone']
|
||||||
elif name<root['name']:
|
elif name<root['name']:
|
||||||
return bst_find(root['left'], name)
|
return bst_find(root['left'], name)
|
||||||
|
|
@ -269,7 +269,7 @@ def bst_delete(root,name):
|
||||||
if root['left'] is None:
|
if root['left'] is None:
|
||||||
return root['right']
|
return root['right']
|
||||||
if root['right'] is None:
|
if root['right'] is None:
|
||||||
return root['rihgt']
|
return root['right']
|
||||||
|
|
||||||
min_node = find_min(root['right'])
|
min_node = find_min(root['right'])
|
||||||
root['name'] = min_node['name']
|
root['name'] = min_node['name']
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user