[1] FINISH 1-st-exercise #148

Merged
git_admin merged 23 commits from IvanBud123/2026-rff_mp:1-st-exercise into develop 2026-03-15 06:42:24 +00:00
Showing only changes of commit 28de33a83d - Show all commits

View File

@ -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']