forked from UNN/2026-rff_mp
Compare commits
No commits in common. "242abe433daff2d0430b564cd12d9116d666463c" and "057c7188bdd2991e583b4bf40c965a67552329ee" have entirely different histories.
242abe433d
...
057c7188bd
|
|
@ -117,43 +117,3 @@ print("====== TESTING ll_list_all FUNC ======")
|
||||||
print(ll_list_all(head))
|
print(ll_list_all(head))
|
||||||
|
|
||||||
print("====== END ======")
|
print("====== END ======")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
SIZE = 5
|
|
||||||
buckets = [None] * SIZE
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def hash_function(name, size):
|
|
||||||
return hash(name) % size
|
|
||||||
|
|
||||||
|
|
||||||
def ht_insert(buckets, name, phone):
|
|
||||||
index = hash_function(name, len(buckets))
|
|
||||||
head = buckets[index]
|
|
||||||
new_head = ll_insert(head, name, phone)
|
|
||||||
buckets[index] = new_head
|
|
||||||
|
|
||||||
print(f"\n\n\n ====== TEST INSERT HASH ======")
|
|
||||||
print(buckets)
|
|
||||||
ht_insert(buckets, "Ivan", "123-456")
|
|
||||||
print(buckets)
|
|
||||||
ht_insert(buckets, "Dima", "789-123")
|
|
||||||
print(buckets)
|
|
||||||
ht_insert(buckets, "Boris", "456-789")
|
|
||||||
print(buckets)
|
|
||||||
print("====== END TEST ======\n\n\n")
|
|
||||||
|
|
||||||
|
|
||||||
def ht_find(buckets, name):
|
|
||||||
index = hash_function(name, len(buckets))
|
|
||||||
head = buckets[index]
|
|
||||||
return ll_find(head, name)
|
|
||||||
|
|
||||||
print("====== TEST FIND HASH FUN ======")
|
|
||||||
print("find by name Ivan: ",ht_find(buckets, "Ivan"))
|
|
||||||
print("find by name Dima: ",ht_find(buckets, "Dima"))
|
|
||||||
print("find by name Boris: ", ht_find(buckets, "Boris"))
|
|
||||||
print("====== END TEST ======")
|
|
||||||
|
|
||||||
|
|
|
||||||
3
BudakovIS/docs/hash.py
Normal file
3
BudakovIS/docs/hash.py
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
SIZE = 1000
|
||||||
|
buckets = [None] * SIZE
|
||||||
|
|
||||||
Loading…
Reference in New Issue
Block a user