In this lab, we will write a program to handle inserts to a dynamically allocated array or ArrayList using a hash algorithm and a collision resolution algorithm. You can just write the code inside a method main to do the following;
a) Declare a dynamically allocated array or ArrayList object called dataItems of 100 String objects.
Think about both of these options – what code needs to be in the constructor???
b) Write a menu loop which allows these options
· Add a String to the array dataItems –
o Prompt user to enter a String
o use a hash algorithm to calculate the index of where to store the string in the dataItems array
o the algorithm should be the first letter of the string to be added (converted to an int) added to the second letter of the input string if there is one (converted to an int) – modulus 100 (so that you make sure the result is a number between 0 and 99.
o if there is already a String in this index position – move to the next sequential element position in the array until you find an empty location (but not past 99! – in this case display error message – String cannot be added)
· search for a String in the array dataItems as efficiently as possible– and display the index of where it is found or a message if it is not found