Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using Python & Hash Using Python & Hash Table Lab Exercise: You need to implement the followings: 1. Class HashTable that includes the instance variables:

Using Python

& Hash

image text in transcribed

image text in transcribed

image text in transcribed

Using Python

& Hash Table

Lab Exercise: You need to implement the followings: 1. Class HashTable that includes the instance variables: array # Hash Table array sise # Hash Table size Your class should have the following: Constructor that creates the array and save the size of the hash table. hashFun(name) Find the summation of characters ASCII values then apply the following function key = sum % self.size Use ord(character)-96 to convert a character in the name to int. insert(name) Insert the name in the proper location. Use linear propping when a collision happens. If the hash table is full return false. Hint: Use the function hashFun find(name) Search the Hash Table for name and return True if it was found. Hint: Use the function hashFun print() Print the contents of the Hash Table. Print (****) if the slot was empty. Write the expected time and space complexity as a comment at the beginning of each method of your class. 2. Write a test program named Lab1oTest. Do the following: Create an object of class HashTable with size = 10 Display a menu to the user asking for a choice to be entered as follows: The program can perform the following: 1- Insert a name 2- Search for a name 3- Print hash table 4- Exit Please enter your selection: The program will perform the action selected by the user and display a proper message when necessary. The program will repeat these actions until the user terminates the program (Hint: Use a loop). Sample Output The program can perform the following: 1- Insert a name 2- Search for a name 3- Print hash table 4- Exit Please enter your selection: 3 Cell Data 0 1 2 3 4 5 6 7 8 9 The program can perform the following: 1- Insert a name 2- Search for a name 3- Print hash table 4- Exit Please enter your selection: 1 Enter a name for * to stop): Sarah Enter a name for to stop): Abeer Enter a name for * to stop): Basma Enter a name for to stop): Zainab Enter a name for to stop): Layla Enter a name for to stop): Aisha Enter a name (or to stop): Anwar Enter a name (or to stop): Hana Enter a name for * to stop): Amal Enter a name for to stop): Shaikha Enter a name for to stop): Maha The hash table is full.. Enter a name for to stop): The program can perform the following: 1- Insert a name 2- Search for a name 3- Print hash table 4- Exit Please enter your selection: 3 Cell Data 0 Layla 1 Zainab 2 Hana 3 Shaikha 4 Basma 5 Sarah 6 Aisha 7 Anwar 8 Amal 9 Abeer The program can perform the following: 1- Insert a name 2- Search for a name 3- Print hash table 4- Exit Please enter your selection: 2 Enter a name: Abeer Abeer was found in the table The program can perform the following: 1- Insert a name 2- Search for a name 3- Print hash table 4- Exit Please enter your selection: 2 Enter a name: Maha Maha was not found in the table The program can perform the following: 1- Insert a name 2- Search for a name 3- Print hash table

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

C++ Database Development

Authors: Al Stevens

1st Edition

1558283579, 978-1558283572

More Books

Students also viewed these Databases questions

Question

An example of differentiation by location is:

Answered: 1 week ago