Question: data structures using java Lab Exercise: You need to implement the followings: 1. Class HashTable that includes the instance variables: String A[]; int size; Your
data structures using java

![1. Class HashTable that includes the instance variables: String A[]; int size;](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f3d58108387_93666f3d58087186.jpg)


Lab Exercise: You need to implement the followings: 1. Class HashTable that includes the instance variables: String A[]; int size; Your class should have the following: public HashTable(int n) Create an array of strings and save the size of the hash table. public int hashFun(String s) Find the summation of characters ASCII values then apply the following function key = sum % size Use myString.charAt(int index) to get the character at location index in the string s then cast it to an in integer using (int) to get the ASCII value. public boolean insert(String s) Insert the name s in the proper location. Use linear propping when a collision happens. If the hash table is full return true. Hint: Use the function hashFun public boolean find(String s) Search the Hash Table for s and return true if it was found. Hint: Use the function hashFun public void 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 application named Lab9Test. In the main method, do the following: Create an object of class HashTable. Display a menu to the user and 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). 5 6 7 8 9 Basma Sarah Aisha Zainab Anwar 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: Basma Basma 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 4- Exit Please enter your selection: 4 Exiting the program... 2. Write a test application named Lab9Test. In the main method, do the following: Create an object of class HashTable. Display a menu to the user and 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)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
