Question: Modify the class BasicHashTable with double hashing (hash2(key)=5-key%5) such that it stores a list of probe sequences for inserted keys. The class should have the

Modify the class BasicHashTable with double hashing (hash2(key)=5-key%5) such that it stores a list of probe sequences for inserted keys.

The class should have the following attributes:

class BasicHashTable:

def __init__(self,size=7):

self.size = size

self.slots = [None] * self.size

self.probeSequences = [[]] * self.size

The list probeSequences contains initially an empty list for each slot. If a key is inserted into slots[k] then probeSequences[k] should contain the entire probe sequence produced when inserting that key

Please write the code in python

Test:

hash_t = BasicHashTable() #default table size is 7 hash_t.put(3) hash_t.put(20) hash_t.put(10) print(hash_t.slots) print(hash_t.probeSequences)

Result:

[None, 10, None, 3, None, None, 20] [[], [3, 1], [], [3], [], [], [6]]

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!