Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

part:1 https://www.chegg.com/homework-help/questions-and-answers/81-open-hash-table-implement-open-hash-table-hash-table-take-numbers-input-hash-function-h-q44275434?trackid=bJjSQsao python 8.2 Closed Hash Table Implement an Closed Hash Table. Your Hash table will only take numbers as input. Your hash function will

part:1 https://www.chegg.com/homework-help/questions-and-answers/81-open-hash-table-implement-open-hash-table-hash-table-take-numbers-input-hash-function-h-q44275434?trackid=bJjSQsao

python

image text in transcribedimage text in transcribed

image text in transcribed

8.2 Closed Hash Table Implement an Closed Hash Table. Your Hash table will only take numbers as input. Your hash function will be hash(val, size) = val % size Your rehash strategy will be rehash(val, k, size) = (hash(val, size) + k) % N You must implement the following functions Constructor: takes number of rows in column String Method: prints one line for each row in the format shown below hash: Implements the hash function rehash: Implement rehash strategy insert: Inserts number into hash table (ignore duplicates) member: returns True if number is in hash table and false otherwise delete: removes the number from hash table if it exists You are provided with a test script which will use your Closed Hash Table. An example execution is provided below. An example execution is provided below. Welcome to closed Hash Table Tests How big would you like your hash table to be? Enter a seed for the random number generator: 65 Created an Empty Hash Table Row 0 None Row 1 None Insert Random Numbers in range 0 to 5n Inserting 6 into hash table After Insert your hash table looks like: Row 06 Row 1 None Inserting 4 into hash table After Insert your hash table looks like: Row 0 6 Row 1 4 Testing Member on all numbers from 0 to 5n Passed 10 out of 10 Deleting all values in Hash Deleting value 6 After Delete your hash table looks like: Row O None Row 1 4 Deleting value 4 After Delete your hash table looks like: Row 0 None Row 1 None 1 #Implement an Closed hash table with 2 #hash function hash(i,N)=i mod n 3 #Rehash Strategy: rehash(i,k,N)= (hash(i,N)+k) mod N 5 class closedHash: def __init__(self,n): return def __str__(self): return def hash(self,i): return def rehash(self,i,k): return def insert(self, num): return def member(self, num): return def delete(self, num): return 8.2 Closed Hash Table Implement an Closed Hash Table. Your Hash table will only take numbers as input. Your hash function will be hash(val, size) = val % size Your rehash strategy will be rehash(val, k, size) = (hash(val, size) + k) % N You must implement the following functions Constructor: takes number of rows in column String Method: prints one line for each row in the format shown below hash: Implements the hash function rehash: Implement rehash strategy insert: Inserts number into hash table (ignore duplicates) member: returns True if number is in hash table and false otherwise delete: removes the number from hash table if it exists You are provided with a test script which will use your Closed Hash Table. An example execution is provided below. An example execution is provided below. Welcome to closed Hash Table Tests How big would you like your hash table to be? Enter a seed for the random number generator: 65 Created an Empty Hash Table Row 0 None Row 1 None Insert Random Numbers in range 0 to 5n Inserting 6 into hash table After Insert your hash table looks like: Row 06 Row 1 None Inserting 4 into hash table After Insert your hash table looks like: Row 0 6 Row 1 4 Testing Member on all numbers from 0 to 5n Passed 10 out of 10 Deleting all values in Hash Deleting value 6 After Delete your hash table looks like: Row O None Row 1 4 Deleting value 4 After Delete your hash table looks like: Row 0 None Row 1 None 1 #Implement an Closed hash table with 2 #hash function hash(i,N)=i mod n 3 #Rehash Strategy: rehash(i,k,N)= (hash(i,N)+k) mod N 5 class closedHash: def __init__(self,n): return def __str__(self): return def hash(self,i): return def rehash(self,i,k): return def insert(self, num): return def member(self, num): return def delete(self, num): return

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

Professional Microsoft SQL Server 2014 Administration

Authors: Adam Jorgensen, Bradley Ball

1st Edition

111885926X, 9781118859261

More Books

Students also viewed these Databases questions