Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Big Data Systems A 360-degree Approach

Authors: Jawwad ShamsiMuhammad Khojaye

1st Edition

0429531575, 9780429531576

More Books

Students also viewed these Databases questions

Question

What do Dimensions represent in OLAP Cubes?

Answered: 1 week ago