добавлен файл с генерацией тестовых данных
This commit is contained in:
parent
d43389ec5e
commit
274784ea0a
0
konnovaea/experiments.py
Normal file
0
konnovaea/experiments.py
Normal file
|
|
@ -1,13 +1,16 @@
|
|||
def ll_insert(head, name, phone):
|
||||
current = head
|
||||
while current is not None:
|
||||
if current['name'] == name:
|
||||
current['phone'] = phone
|
||||
return head
|
||||
current = current['next']
|
||||
|
||||
new_node = {'name': name, 'phone': phone, 'next': head}
|
||||
return new_node
|
||||
new_node = {'name': name, 'phone': phone, 'next': None}
|
||||
|
||||
if head is None:
|
||||
return new_node
|
||||
|
||||
current = head
|
||||
while current['next'] is not None:
|
||||
current = current['next']
|
||||
|
||||
current['next'] = new_node
|
||||
return head
|
||||
|
||||
def ll_find(head, name):
|
||||
current = head
|
||||
|
|
@ -25,7 +28,7 @@ def ll_delete(head, name):
|
|||
current = head
|
||||
while current['next'] is not None:
|
||||
if current['next']['name'] == name:
|
||||
current['next'] = current['naext']['next']
|
||||
current['next'] = current['next']['next']
|
||||
return head
|
||||
current = current['next']
|
||||
return head
|
||||
|
|
@ -35,7 +38,7 @@ def ll_list_all(head):
|
|||
current = head
|
||||
|
||||
while current is not None:
|
||||
records.append((current['name'], current['phine']))
|
||||
records.append((current['name'], current['phone']))
|
||||
current = current['next']
|
||||
records.sort(key=lambda x: x[0])
|
||||
return records
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user