Question: Help In Java ! Create a hash table of size 121. Put 1 00 words into it using the file words_no_duplicates.txt.Handle collisions by LINEAR PROBING.
Help In Java!
Create a hash table of size 121. Put 100 words into it using the file words_no_duplicates.txt.Handle collisions by LINEAR PROBING.
You should have a method to add each word to the table. You should also count the average number of accesses to find all the words. Note: when you insert using linear probing you can count as you insert. Then you need another method to count the average number of accesses to find that a word is NOT in the table. You will need to first build the table and then run this last method.
Dont use use the Hash class that Java provides. I want you to do this using just an array. BUT it doesn't have to be an array of strings. If it helps you to put an object into the array that holds more than the string, that's OK. Not saying you have to - there are several ways to write this program, the output will be the same.
I asked you to use just the first 100 words of the file with no duplicates because some students may run out of RAM. I also purposely chose a bad hash function that creates lots of duplicates.
The total number of probes in a successful search is 3127 The average number of probes in a successful search is 31.27 The total number of probes in an unsuccessful search is 4880 The average number of probes in an unsuccessful search is 40.33057851239669
What i have so far
public static void main(String[] args) {
File Filee = new File("words.txt");
Scanner fileInput = null;
Scanner k = new Scanner (System.in);
try {
fileInput = new Scanner(Filee);
}
catch (FileNotFoundException e) {
}
int i = 0;
while (i != 100){
String word = fileInput.nextLine();
int v = (int) word.charAt(0);
int s = (int) word.charAt(1);
int words = (a + b) % 121;
System.out.println( i + " " + word + " " + words);
i++;
}
}
Here is the words
}
noncollectable reallocation drenching obnoxious venalit dybbuk shotgun changelessly and1work unheralded dovecote anode spellbind psychologist improvisational prejudiced apply pokey secular masterfully overdrawn costar scruff awareness impurely tuft minstrelsy calcimine mescal mussel controversial insulin presentation convertibility fop spiry tearful unconditioned leftism detainee perversity unforgivably begin hooey noncollectable reallocation drenching obnoxious venalit dybbuk shotgun changelessly and1work unheralded dovecote anode spellbind psychologist improvisational prejudiced apply pokey secular masterfully overdrawn costar scruff awareness impurely tuft minstrelsy calcimine mescal mussel controversial insulin presentation convertibility fop spiry tearful unconditioned leftism detainee perversity unforgivably begin hooey
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
