diff --git a/VolkovVA/cod.py b/VolkovVA/cod.py index 25c43b5..65d46fc 100644 --- a/VolkovVA/cod.py +++ b/VolkovVA/cod.py @@ -1,5 +1,5 @@ import random as rnd -<<<<<<< HEAD + def ll_insert(head, name, phone): new_node = {'name': name, 'phone': phone, 'next': None} @@ -61,5 +61,21 @@ def ll_list_all(head): current = current['next'] res = sort_records(record) return res -======= ->>>>>>> 221b0dbe36c30826c59c8721814c9bb881eafeee + + + + + + +def def_hash(name, size): + hash_value = 0 + for char in name: + hash_value += ord(char) + 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) +