Question: /* Project1.java Dynamic histogram */ import java.io.*; import java.util.*; public class Project1 { static final int INITIAL_CAPACITY = 10; public static void main (String[] args)

 /* Project1.java Dynamic histogram */ import java.io.*; import java.util.*; public class Project1 { static final int INITIAL_CAPACITY = 10; public static void main (String[] args) throws Exception { // ALWAYS TEST FIRST TO VERIFY USER PUT REQUIRED INPUT FILE NAME ON THE COMMAND LINE if (args.length  java Project1  "); // i.e. C:\> java Project1 dictionary.txt System.exit(0); } int[] histogram = new int[0]; // histogram[i] == # of words of length n /* array of String to store the words from the dictionary. We use BufferedReader (not Scanner). With each word read in, examine it's length and update word length frequency histogram accordingly. */ String[] wordList = new String[INITIAL_CAPACITY]; int wordCount = 0; BufferedReader infile = new BufferedReader( new FileReader(args[0]) ); while ( infile.ready() ) { String word = infile.readLine(); // # # # # # DO NOT WRITE/MODIFY ANYTHING ABOVE THIS LINE # # # # # // test to see if list is full. If needed do an up size (just like Lab#3) // now you may safely append word onto list and incr count // look at the word length and see if the histogram length is AT LEAST // word length + 1. If not, you must upsize histogram to be EXACTLY word length + 1 // now you can increment the counter in the histogram for this word's length // # # # # # DO NOT WRITE/MODIFY ANYTHING BELOW THIS LINE # # # # # } //END WHILE INFILE READY infile.close(); wordList = trimArr( wordList, wordCount ); System.out.println( "After final trim: wordList length: " + wordList.length + " wordCount: " + wordCount ); // PRINT WORD LENGTH FREQ HISTOGRAM for ( int i = 0; i  

 /* Project1.java Dynamic histogram */ import java.io.*; import java.util.*; public class

You will load tbe dictionary into the array azd zesize the array (by doubling its current length) ks needed ? rti se t ects 12. As eacl werd is zea in you wan ???0 update an ?1ay cf f equency co a tezs that record bow manr words of langth 1 or length ete ware the file he istogram 1sjteta p an array o nt t at ? nitiahZed to ength zero. eca that Jys, ows us to etrie ? Tew array ma a eng of zero t Mppe e enery tume you r n ? ? 3 progre ? 20 command ue ar un ente ou g 50 titu lizes t e arge array to have ength aaro. Every time you read a word from the dictsonary you cannot just exeeute s lreeat stateaeut such as ++hastogran[word , length() ] ? TI s s the correct statement toess ute, but Fou must ast ma e suze the histogram is cag ough te have ? oell at that a dex If your eurent wed has enh of Fou Lucst first Lake sure that your hatogram array has ? kngth of at least 8 (not 7 because t e 7 ce 1 of the rray is actally the eighth cel. Wheaver you enoounser word whose leagth is >= th" laggth of your freq ou a az arvay. upsLZG your ceaatar array to be just bag acueaaength +2) ar tba: pausealaz lea gt?value i gtL+ 1 At the end of the pre su:t s pass bl that you eould have gaps in your histogram ! depending on the input file) there were no words of length-or 13er 2?and ee ea. In tbie ca.ee ther"reald eral] be a zero at index 7 or 13 or 26, :\Users\t??Desktop>java Praject1 dictionary. txt fter final tri: wordList lenoth: 172822 wordCount: 172822 ords of length 0 ords of length ords of length ords of length ords of 1ength ords of length ords of Tength ords of length ords of length ords of length 10 20302 ords of length 11 15504 ords of length 12 1135 ords of length 13 78 ords of length 14 5127 ords of length 15 3192 ords of length 16 1943 ords of Tength 17 1127 3903 8636 15232 ords of length ords of length ords of length ords of length ords of length ords of Tength ords of length ords of length 27 ords of length 28 2 You will load tbe dictionary into the array azd zesize the array (by doubling its current length) ks needed ? rti se t ects 12. As eacl werd is zea in you wan ???0 update an ?1ay cf f equency co a tezs that record bow manr words of langth 1 or length ete ware the file he istogram 1sjteta p an array o nt t at ? nitiahZed to ength zero. eca that Jys, ows us to etrie ? Tew array ma a eng of zero t Mppe e enery tume you r n ? ? 3 progre ? 20 command ue ar un ente ou g 50 titu lizes t e arge array to have ength aaro. Every time you read a word from the dictsonary you cannot just exeeute s lreeat stateaeut such as ++hastogran[word , length() ] ? TI s s the correct statement toess ute, but Fou must ast ma e suze the histogram is cag ough te have ? oell at that a dex If your eurent wed has enh of Fou Lucst first Lake sure that your hatogram array has ? kngth of at least 8 (not 7 because t e 7 ce 1 of the rray is actally the eighth cel. Wheaver you enoounser word whose leagth is >= th" laggth of your freq ou a az arvay. upsLZG your ceaatar array to be just bag acueaaength +2) ar tba: pausealaz lea gt?value i gtL+ 1 At the end of the pre su:t s pass bl that you eould have gaps in your histogram ! depending on the input file) there were no words of length-or 13er 2?and ee ea. In tbie ca.ee ther"reald eral] be a zero at index 7 or 13 or 26, :\Users\t??Desktop>java Praject1 dictionary. txt fter final tri: wordList lenoth: 172822 wordCount: 172822 ords of length 0 ords of length ords of length ords of length ords of 1ength ords of length ords of Tength ords of length ords of length ords of length 10 20302 ords of length 11 15504 ords of length 12 1135 ords of length 13 78 ords of length 14 5127 ords of length 15 3192 ords of length 16 1943 ords of Tength 17 1127 3903 8636 15232 ords of length ords of length ords of length ords of length ords of length ords of Tength ords of length ords of length 27 ords of length 28 2

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!