Question: Modify the class BasicHashTable such that it implements quadratic probing. class BasicHashTable: def __init__(self,size=7): self.size = size self.slots = [None] * self.size def hash_function(self, key):
Modify the class BasicHashTable such that it implements quadratic probing.
class BasicHashTable:
def __init__(self,size=7):
self.size = size
self.slots = [None] * self.size
def hash_function(self, key): ... # implements key % table_size
def rehash(self, old_hash): ... # implement linear probing
The class should have a hash, rehash and put method in python
Please add a put function "def put(self, key)" for inserting a value into the hash table.
Test:
hash_t = BasicHashTable() #default table size is 7 hash_t.put(3) hash_t.put(17) hash_t.put(10) print(hash_t.slots)
Result:
[10, None, None, 3, 17, None, None]
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
