[1] 1-st-exercise #2

Open
volkovva wants to merge 15 commits from 1-st-exercise into develop
Showing only changes of commit c5baf3661a - Show all commits

View File

@ -74,8 +74,31 @@ def def_hash(name, size):
final_idx = hash_value % size
return final_idx
def ht_insert(buckets, name, phone):
size = len(buckets)
idx = def_hash(name, size)
ll_insert(buckets[idx], name, phone)
def ht_find(buckets, name):
size = len(buckets)
idx = def_hash(name, size)
return ll_find(buckets[idx], name)
def ht_delete(buckets, name):
size = len(buckets)
idx = def_hash(name, size)
buckets[idx] = ll_delete(buckets[idx], name)
def ht_list_all(buckets):
res = []
for head in buckets:
current = head
while current is not None:
res += [(current['name'], current['phone'])]
current = current['next']
return sort_records(res)