Question #256285

Write a python program to implement hash table with quadratic probing 1) insert item into hash table 2) remove item into hash table 3) check the size of hash table 4) Display Hash table

Expert's answer

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)
LATEST TUTORIALS
APPROVED BY CLIENTS