forked from UNN/2026-rff_mp
develop #1
BIN
LarikovaAA/.DS_Store
vendored
BIN
LarikovaAA/.DS_Store
vendored
Binary file not shown.
BIN
LarikovaAA/task1/.DS_Store
vendored
BIN
LarikovaAA/task1/.DS_Store
vendored
Binary file not shown.
|
|
After Width: | Height: | Size: 87 KiB |
BIN
LarikovaAA/task1/task1/.DS_Store
vendored
BIN
LarikovaAA/task1/task1/.DS_Store
vendored
Binary file not shown.
|
|
@ -1,83 +0,0 @@
|
|||
def bst_insert(root, name, phone):
|
||||
new_node = {'name': name, 'phone': phone, 'left': None, 'right': None}
|
||||
|
||||
if root is None:
|
||||
return new_node
|
||||
|
||||
current = root
|
||||
while True:
|
||||
if name < current['name']:
|
||||
if current['left'] is None:
|
||||
current['left'] = new_node
|
||||
break
|
||||
else:
|
||||
current = current['left']
|
||||
elif name > current['name']:
|
||||
if current['right'] is None:
|
||||
current['right'] = new_node
|
||||
break
|
||||
else:
|
||||
current = current['right']
|
||||
else:
|
||||
current['phone'] = phone
|
||||
break
|
||||
|
||||
return root
|
||||
|
||||
|
||||
def bst_find(root, name): #Итеративный поиск в BST
|
||||
current = root
|
||||
while current is not None:
|
||||
if name == current['name']:
|
||||
return current['phone']
|
||||
elif name < current['name']:
|
||||
current = current['left']
|
||||
else:
|
||||
current = current['right']
|
||||
return None
|
||||
|
||||
|
||||
def bst_find_min(root): #Поиск минимального узла
|
||||
current = root
|
||||
while current['left'] is not None:
|
||||
current = current['left']
|
||||
return current
|
||||
|
||||
|
||||
def bst_delete(root, name): # Рекурсия только в глубину
|
||||
if root is None:
|
||||
return None
|
||||
|
||||
if name < root['name']:
|
||||
root['left'] = bst_delete(root['left'], name)
|
||||
elif name > 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']
|
||||
else:
|
||||
min_node = bst_find_min(root['right'])
|
||||
root['name'] = min_node['name']
|
||||
root['phone'] = min_node['phone']
|
||||
root['right'] = bst_delete(root['right'], min_node['name'])
|
||||
return root
|
||||
|
||||
|
||||
def bst_list_all(root, records=None): #Возвращает отсортированные записи
|
||||
if records is None:
|
||||
records = []
|
||||
|
||||
stack = []
|
||||
current = root
|
||||
|
||||
while stack or current:
|
||||
while current is not None:
|
||||
stack.append(current)
|
||||
current = current['left']
|
||||
current = stack.pop()
|
||||
records.append((current['name'], current['phone']))
|
||||
current = current['right']
|
||||
|
||||
return records
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
N = 10000 # Количество записей
|
||||
REPEATS = 5 # Количество повторений каждого эксперимента
|
||||
HASH_TABLE_SIZE = 1000 # Размер хеш-таблицы
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
import random
|
||||
|
||||
|
||||
def generate_test_data(N): #Генерирует N записей с именами User_00000 ... User_N-1
|
||||
records = [(f"User_{i:05d}", f"+7-999-{i:05d}") for i in range(N)]
|
||||
|
||||
records_shuffled = records.copy()
|
||||
random.shuffle(records_shuffled)
|
||||
|
||||
records_sorted = sorted(records, key=lambda x: x[0])
|
||||
|
||||
return records, records_shuffled, records_sorted
|
||||
|
||||
|
||||
def get_names_for_operations(records, num_find=100, num_delete=50, num_nonexistent=10): #Подготавливает имена для операций поиска и удаления
|
||||
existing_names = [name for name, _ in records[:num_find + num_delete]]
|
||||
names_to_find = existing_names[:num_find] + [f"None_{i}" for i in range(num_nonexistent)]
|
||||
names_to_delete = existing_names[num_find:num_find + num_delete]
|
||||
|
||||
return names_to_find, names_to_delete
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
Структура,Режим,Операция,Повтор1,Повтор2,Повтор3,Повтор4,Повтор5,Среднее,Стд_откл
|
||||
linkedlist,случайный,вставка,3.030525333015248,3.011153083993122,3.067337290965952,3.026814332988579,3.0305452499887906,3.0332750581903385,0.018473609585193725
|
||||
linkedlist,случайный,поиск,0.023072624986525625,0.023000167042482644,0.023063208034727722,0.023132542031817138,0.023077582998666912,0.02306922501884401,4.2179776992719985e-05
|
||||
linkedlist,случайный,удаление,0.01565887499600649,0.01571191701805219,0.01575241598766297,0.015799874963704497,0.015716666996013373,0.015727949992287903,4.674933972158777e-05
|
||||
linkedlist,отсортированный,вставка,2.7900312499841675,2.842725833004806,2.8324795000371523,2.8226387499598786,2.824206833029166,2.822416433203034,0.01769628256337186
|
||||
linkedlist,отсортированный,поиск,0.0026340839685872197,0.0026223339955322444,0.002628166985232383,0.0026764170033857226,0.0026917500072158873,0.0026505503919906914,2.805286048400875e-05
|
||||
linkedlist,отсортированный,удаление,0.00025987502885982394,0.00026162504218518734,0.0002579580177552998,0.00026395899476483464,0.00025770795764401555,0.00026022500824183223,2.3452089690404486e-06
|
||||
hashtable,случайный,вставка,0.19747637503314763,0.1957802499528043,0.195026625005994,0.1953300409950316,0.1995006250217557,0.19662278320174664,0.001669692081198908
|
||||
hashtable,случайный,поиск,0.0007510409923270345,0.0007478750194422901,0.0007428750395774841,0.0007420409820042551,0.0007448329706676304,0.0007457330008037389,3.327822630240364e-06
|
||||
hashtable,случайный,удаление,0.00037333305226638913,0.0003679579822346568,0.0003666249685920775,0.000368500011973083,0.00036679196637123823,0.00036864159628748896,2.448879400144638e-06
|
||||
hashtable,отсортированный,вставка,0.19373183301649988,0.19131775002460927,0.20354575000237674,0.19244924996746704,0.19410508294822648,0.19502993319183587,0.004370349591521971
|
||||
hashtable,отсортированный,поиск,7.366598583757877e-05,7.358303992077708e-05,7.379200542345643e-05,7.329200161620975e-05,7.29589955881238e-05,7.345840567722917e-05,2.9900259428386626e-07
|
||||
hashtable,отсортированный,удаление,5.0292001105844975e-05,5.037500523030758e-05,5.124998278915882e-05,5.0540955271571875e-05,5.050003528594971e-05,5.059159593656659e-05,3.409075164884719e-07
|
||||
bst,случайный,вставка,0.012036708008963615,0.011527249997016042,0.011410709004849195,0.011799749976489693,0.011473792023025453,0.011649641802068799,0.00023466763426973204
|
||||
bst,случайный,поиск,6.741698598489165e-05,8.07500327937305e-05,6.450002547353506e-05,6.416701944544911e-05,6.570800906047225e-05,6.850841455161572e-05,6.225842896923898e-06
|
||||
bst,случайный,удаление,5.729199619963765e-05,5.966599564999342e-05,5.4165953770279884e-05,5.4958974942564964e-05,5.529198097065091e-05,5.627498030662537e-05,1.9839081193124104e-06
|
||||
bst,отсортированный,вставка,3.063095625024289,3.0107702090172097,3.0406965000438504,2.9900419160258025,3.014387540984899,3.02379835821921,0.025407148276338564
|
||||
bst,отсортированный,поиск,0.0002975420211441815,0.0002921670093201101,0.00029941595857962966,0.0002905830042436719,0.00029925000853836536,0.0002957916003651917,3.6993963362568915e-06
|
||||
bst,отсортированный,удаление,0.0003683330141939223,0.00036570901283994317,0.00037129101110622287,0.0003595000016503036,0.0003665830008685589,0.00036628320813179014,3.891304706952938e-06
|
||||
|
Gitea Version: 1.22.0 |
