Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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.
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started