def ll_insert(head, name, phone): current = head while current: if current['name'] == name: current['phone'] = phone return head current = current['next'] new_node = {'name': name, 'phone': phone, 'next': None} new_node['next'] = head return new_node def ll_find(head, name): current = head while current: if current['name'] == name: return current['phone'] current = current['next'] return None def ll_delete(head, name): if head['name'] == name: return head['next'] current = head while current['next']: if current['next']['name'] == name: current['next'] = current['next']['next'] break current = current['next'] return head def quick_sort(arr): if len(arr) <= 1: return arr left = [] middle = [] right = [] pivot = arr[len(arr) // 2][0] for x in arr: if x[0] root['name']: root['right'] = bst_delete(root['right'], name) else: if root['left'] is None: return root['right'] elif root['right'] is None: return root['left'] min=minimum(root['right']) root['name']=min['name'] root['phone']=min['phone'] root['right']=bst_delete(root['right'], min['name']) return root def bst_list_all(root): result=[] if root: result.extend(bst_list_all(root['left'])) result.append((root['name'], root['phone'])) result.extend(bst_list_all(root['right'])) return result