Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Informix Database Administrators Survival Guide

Authors: Joe Lumbley

1st Edition

0131243144, 978-0131243149

More Books

Students also viewed these Databases questions

Question

c. How is trust demonstrated?

Answered: 1 week ago

Question

Have issues been prioritized?

Answered: 1 week ago

Question

d. How will lack of trust be handled?

Answered: 1 week ago