There was an error while loading. Please reload this page.
1 parent a6cad98 commit 80afe9eCopy full SHA for 80afe9e
Section_11(Hash-Table)/(2)_hash-table-linear-probing.py
@@ -15,5 +15,15 @@ def __init__(self):
15
self.hashtable_size = 10
16
self.hashtable = [0] * self.hashtable_size
17
18
+ # Hashing function
19
def hashcode(self, key):
20
return key % self.hashtable_size
21
+
22
+ # Function to compute next index to insert element if index already
23
+ # has an element stored in the Hash Table
24
+ def lprobe(self, element):
25
+ i = self.hashcode(element)
26
+ j = 0
27
+ while self.hashtable[(i + j) % self.hashtable_size] != 0:
28
+ j = j + 1
29
+ return (i + j) % self.hashtable_size
0 commit comments