[1] 1-st-exercise #2

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

View File

@ -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)