Question: Need help to write a java program that creates a list of each word from a given txt document along with the number of times

Need help to write a java program that creates a list of each word from a given txt document along with the number of times that word appears. I have to use a hash tables of sizes 500, 1000, and 2000. The hash table should contain a linked list in each slot to keep a record of the words within the hash. Have to use linkedlist to store the collisions if there are any. The program needs to print out a file that contains each word and the number of times it appears into a CSV so that it can be reviewed in an Excel.

Your program should create hash tables of various sizes: 500, 1000, 2000, 5000 and 10000 slots. The hash table should use a linked list in each slot to keep track of the words that hash to that slot. It should read each word in the novel, then search for or insert the word in the hash table based on the hash function: Math.abs(myString.hashCode()%tablesize).

The program should use LinkedLists to store collisions. You do not need to write your own linked list. When adding an item to the list, use an Iterator or ListIterator to determine whether the word is already in the table. Doing this will enable you to keep track of the number of steps required to look up and add the word. Your program should keep track of the number of occurrences of each word, and the number of steps it took to find or insert the word. Number of steps is based on the position of the word in the linked list. If the word is first, it took 1 step to find. If the word is second, it took 2 steps to find, etc.

The program should print a file that contains each word, the number of occurrences of that word, and the number of steps it took to find the word. Make the file a CSV so that you can read it in Excel. Use Excel to calculate statistics such as the total number of words, the total number of occurrences, total steps, and average steps per word. Make a chart that plots the average number of steps against the size of the hash table.

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 Databases Questions!