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] *

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!