develop #1

Open
FirsovAV wants to merge 1141 commits from UNN/2026-rff_mp:develop into develop
Showing only changes of commit 41433c287a - Show all commits

View File

@ -46,4 +46,30 @@ def ll_list_all(head):
while current:
records.append((current['name'], current['phone']))
current = current['next']
return sorted(records, key=lambda x: x[0])
def hash_func(name, size):
return sum(ord(c) for c in name) % size
def ht_create(size=1000):
return [None] * size
def ht_insert(table, name, phone):
idx = hash_func(name, len(table))
table[idx] = ll_insert(table[idx], name, phone)
def ht_find(table, name):
idx = hash_func(name, len(table))
return ll_find(table[idx], name)
def ht_delete(table, name):
idx = hash_func(name, len(table))
table[idx] = ll_delete(table[idx], name)
def ht_list_all(table):
records = []
for bucket in table:
current = bucket
while current:
records.append((current['name'], current['phone']))
current = current['next']
return sorted(records, key=lambda x: x[0])