def display(array1, n):
for i in range(n):
print(array1[i], end = "\t")
def Hashing(tb, n, array1, N):
for i in range(N):
v = array1[i] % n
if (tb[v] == -1):
tb[v] = array1[i]
else:
for j in range(n):
t = (v + j * j) % n
if (tb[t] == -1):
tb[t] = array1[i]
break
display(tb, N)
array1 = [ 1,2,3,4,5,6,7,8,9]
N = 9
L = 9
hashTable = [0] * 9
for i in range(L):
hashTable[i] = -1
Hashing(hashTable, L, array1, N)
Comments
Leave a comment