Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Task 1 [7 marks] Implement a complete version of a hash table using Linear Probing to resolve collisions. Include implementations for the following 4 functions:

Task 1 [7 marks]

Implement a complete version of a hash table using Linear Probing to resolve collisions. Include implementations for the following 4 functions:

__getitem__(self, key): Returns the value corresponding to key in the hash table. Raises a KeyError if key does not exist in the hash table. Called by table[key]

__setitem__(self, key, value): Sets the value corresponding to key in the hash table to be value. Raise an exception if the hash table is full and the key does not exist in the table yet. Called by table[key] = value

__contains__(self, key): Returns True if key is in the table and False otherwise.

hash(self, key): Calculates the hash value for the given key.

Task 1 used as reference and code is to be in Python. Need help with Task 3. Thank you :)

image text in transcribed

Task 3 l3 marks nation of values takes too long. In total you should consider 15 possibilities (3 files for each table size). In this task you e implementation to now track the number ofs the word as both, key and data. collisions, the load, as well as the average probe length. For the latter it is advisable to track the total probe length in an instance variable. The average probe length is the total probe length divided by the number of items on the table. Using collisions, probe length and wall time, choose appropriate values of a (in your hash function) and table size. You want to find values that perform well across all three files. For this task use a maximum table size of 400000 You should try at least 1o values, and explain your choice by presenting all data behind your reasoning recorded in a table Just for fun we'll collect the best performer in each lab class

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

Neo4j Data Modeling

Authors: Steve Hoberman ,David Fauth

1st Edition

1634621913, 978-1634621915

More Books

Students also viewed these Databases questions