Question: Program Write a cross - reference java program implemented with hashing so that the program outputs alphabetized list of all words in an input file

Program
Write a cross-reference java program implemented with hashing so that the program outputs alphabetized list of all words in an input file along with line numbers on which these words occur.
For each input word the program determines its home position with a hash function implemented in the program. Create a hash table, which is an array of a particular size initialized with nulls. it will store objects of the class type Word which includes a word/string and a list,
initially empty, to store line numbers of the lines on which this word is found in the file of words. Collision resolution should be implemented with the linear probing technique. If the home position in the hash table is free, an object is put there that includes this word and a one-node linked list with the line number of the line on which the word was encountered. If the position is occupied by an object that already includes this word, add the line number to the list of line numbers in this
object. If the home position is occupied by an object for another word, use linear probing to find in the hash table a free cell if the word has been encountered for the first time or find a cell with an object that already includes this word. During linear probing, start from the beginning of the hash table when its end has been reached. When all positions in the table are occupied, print a message and continue processing the file. To sort the data in the hash table, count how many non-null entries in this table you have, create a new array of the size equal to the count, copy all non-null entries from the hash table to
the new array, sort this new array with
Arrays.sort(a); // see p.19 of the textbook;
and then display it with
System.out.print(Arrays.toString(a)); // same page;
Be sure to use an imported file.
Program Write a cross - reference java program

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!