[1] FINISH 1-st-exercise #148
|
|
@ -221,10 +221,10 @@ def bst_insert(root, name, phone):
|
|||
return create_node(name, phone)
|
||||
|
||||
if name == root['name']:
|
||||
root[phone] = phone
|
||||
root['phone'] = phone
|
||||
elif name < root['name']:
|
||||
root['left'] = bst_insert(root['left'], name, phone)
|
||||
elif name >= root['name']:
|
||||
else:
|
||||
root['right'] = bst_insert(root['right'], name , phone)
|
||||
return root
|
||||
|
||||
|
|
@ -241,7 +241,7 @@ print("====== END TEST =======\n\n\n")
|
|||
def bst_find(root, name):
|
||||
if root is None:
|
||||
return None
|
||||
if name == root['name']
|
||||
if name == root['name']:
|
||||
return root['phone']
|
||||
elif name<root['name']:
|
||||
return bst_find(root['left'], name)
|
||||
|
|
@ -269,7 +269,7 @@ def bst_delete(root,name):
|
|||
if root['left'] is None:
|
||||
return root['right']
|
||||
if root['right'] is None:
|
||||
return root['rihgt']
|
||||
return root['right']
|
||||
|
||||
min_node = find_min(root['right'])
|
||||
root['name'] = min_node['name']
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user