Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

class LinearHashTable: def __init__(self, s=13): self.size = s self.slots = [None] * self.size def hashfunction(self,key,size): return key%size def rehash(self,oldhash,size): # to be completed def __str__(self):

class LinearHashTable: def __init__(self, s=13): self.size = s self.slots = [None] * self.size def hashfunction(self,key,size): return key%size def rehash(self,oldhash,size): # to be completed def __str__(self): return str(self.slots) def put(self,key): #to be completed

Complete the above LinearHashtable class. If a collision occurs, you should use linear probing to determine where the key should be placed.

The 'None' value will be used to represent empty positions in the hashtable. You may not assume that there will always be a position for a key to be placed. Your code should work even if the hashtable is full. The put() method should do nothing if it is used to try and insert a key into a full table.

image text in transcribed

Test Result my hash table-LinearHashTable my_hash_table.put(26) my_hash_table.put(54) my_hash_table.put(94) my_hash_table.put(17) my_hash_table.put(31) my_hash_table.put(77) print(my_hash_table) 26, None, 54, 94, 17, 31, None, None, None, None, None, None, 77]

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

Concepts of Database Management

Authors: Philip J. Pratt, Mary Z. Last

8th edition

1285427106, 978-1285427102

More Books

Students also viewed these Databases questions

Question

What is cost-based pricing? How and why is it used?

Answered: 1 week ago

Question

What is the purpose of an IF THEN statement for this lab?

Answered: 1 week ago