Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
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