Question: 2 . Using the Linear Probing code in tpython as a base, write insert, search and delete functions for: a . A hashtable that implements
Using the Linear Probing code in tpython as a base, write insert, search and delete functions for:
a A hashtable that implements Quadrating Probing
b Implements Double hashing, where the secondary hash function is an argument to Hashtable
constructor
class linearprobing:
def initself n:
self.table None n
self.n n
def insertself key, value:
i hashkey self.n
misses
newi i misses self.n
while self.tablenewi is not None:
k v self.tablenewi
if k key:
break
misses
newi i misses self.n
self.tablenewikey value
def searchself key:
i hashkey self.n
misses
newi i misses self.n
while self.tablenewi is not None:
k v self.tablenewi
if k key:
return v
misses
newi i misses self.n
return None
def deleteself key:
i hashkey self.n
misses
newi i misses self.n
while self.tablenewi is not None:
k v self.tablenewi
if key k:
self.tablenewi None
prev newi
curr misses
newi i curr self.n
while self.tablenewi is not None:
self.tableprev self.tablenewi
prev newi
curr
newi i curr self.n
retur
misses
newi i misses self.n
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
