diff --git a/YanyaevAA/[1].py b/YanyaevAA/[1].py index a346706..79ee6ac 100644 --- a/YanyaevAA/[1].py +++ b/YanyaevAA/[1].py @@ -1,6 +1,3 @@ -def ll_create_node(name, phone): - return {'name': name, 'phone': phone, 'next': None} - def ll_insert(head, name, phone): current = head while current: @@ -8,7 +5,7 @@ def ll_insert(head, name, phone): current['phone'] = phone return head current = current['next'] - new_node = ll_create_node(name, phone) + new_node = {'name': name, 'phone': phone, 'next': None} new_node['next'] = head return new_node @@ -31,10 +28,105 @@ def ll_delete(head, name): 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 +