This commit is contained in:
kirill 2026-04-13 19:02:45 +03:00
parent 4cb30a7747
commit f2df567d0f

View File

@ -0,0 +1,28 @@
from codes.LL import ll_insert, ll_find, ll_delete
def ht_insert(buckets, name, phone):
index = hash(name) % len(buckets)
current_head = buckets[index]
new_head = ll_insert(current_head, name, phone)
buckets[index] = new_head
# print("-"*100)
# print(buskets)
def ht_find(buckets, name):
index = hash(name)%len(buckets)
slot_head = buckets[index]
res_ph = ll_find(slot_head, name)
return res_ph
def ht_delete(buskets, name):
index = hash(name)%len(buskets)
buskets[index] = ll_delete(buskets[index], name)
def ht_list_all(buckets):
all_rec = []
for head in buckets:
current = head
while current is not None:
all_rec.append((current['name'], current['phone']))
current = current['next']
all_rec.sort()
return all_rec