Question: class HashTable: def _ _ init _ _ ( self , m = 1 0 ) : # default initial array length: 1 0 ,
class HashTable:
def initself m:
# default initial array length: threshold:
self.inArray LinkedList for i in rangem
self.size
self.threshold
def addself d:
i self.hashd
self.inArrayiinsertd
self.size
if self.size self.thresholdlenselfinArray:
self.resizeUp
def resizeUpself:
oldArray self.inArray
self.inArray LinkedList for i in rangelenoldArray
for i in rangelenoldArray:
while oldArrayilength :
d oldArrayiremove
self.inArrayselfhashdinsertd
Write a function:
def resizeUpself
that, similarly to the corresponding function for HashTable that we saw in class, doubles the length of the internal linked list and rehashes and reinserts all of the elements.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
