[1] task 1 #180

Open
yanyaevaa wants to merge 7 commits from yanyaevaa/2026-rff_mp:task-1 into develop
Showing only changes of commit db1243ce91 - Show all commits

40
YanyaevAA/[1].py Normal file
View File

@ -0,0 +1,40 @@
def ll_create_node(name, phone):
return {'name': name, 'phone': phone, 'next': None}
def ll_insert(head, name, phone):
current = head
while current:
if current['name'] == name:
current['phone'] = phone
return head
current = current['next']
new_node = ll_create_node(name, phone)
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 ll_list_all(head):
items = []
current = head
while current:
items.append((current['name'], current['phone']))
current = current['next']
return sorted(items) # Сортировка O(N log N)