Question: class LinearHashTable: def __init__(self, s=13): self.size = s self.slots = [None] * self.size def hashfunction(self,key,size): return key%size def rehash(self,oldhash,size): # to be completed def __str__(self):
class LinearHashTable: def __init__(self, s=13): self.size = s self.slots = [None] * self.size def hashfunction(self,key,size): return key%size def rehash(self,oldhash,size): # to be completed def __str__(self): return str(self.slots) def put(self,key): #to be completed
Complete the above LinearHashtable class. If a collision occurs, you should use linear probing to determine where the key should be placed.
The 'None' value will be used to represent empty positions in the hashtable. You may not assume that there will always be a position for a key to be placed. Your code should work even if the hashtable is full. The put() method should do nothing if it is used to try and insert a key into a full table.
![class LinearHashTable: def __init__(self, s=13): self.size = s self.slots = [None] *](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f926a53f135_38866f926a4c2de6.jpg)
Test Result my hash table-LinearHashTable my_hash_table.put(26) my_hash_table.put(54) my_hash_table.put(94) my_hash_table.put(17) my_hash_table.put(31) my_hash_table.put(77) print(my_hash_table) 26, None, 54, 94, 17, 31, None, None, None, None, None, None, 77]
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
