Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I have provided a list of over 19,000 words I randomly created. They are not rea

ID: 3537421 • Letter: I

Question

I have provided a list of over 19,000 words I randomly created. They are not real words with meaning in a given language. All the words are in upper case. In a driver class, read the words in from the file and place each word in an ArrayOrderedList. Then once all the words are in the list, print the contents of the list. Time this process, from opening the file until the entire list has been printed. (see the Calendar class). Print the number of milliseconds elapsed. Then in a separate driver, create an array of 26 OrderedLinkedLists. The first element in this array will be a reference to a linked list that holds all the words that start with the letter 'A', the second element in the array will be a reference to a linked list that holds the words that start with the letter "B' and so on. Open the same input file, put each word in the correct place in the correct linked list and then print each linked list. Again, time this process from the opening of the file until the entire list of words has been printed. /** * This class shows how to get the first letter from * a word to determine which array element its corresponding * linked list is located. * * @author Lorrie Lehmann * @version 2/01/2013 */ public class TestAscii { public static void main(String[] args) { String word = "hello"; int subscript = ((word.toUpperCase()).charAt(0)) - 'A'; System.out.println("the word goes in slot : " + subscript); } } Here is the link to the wordfile.txt https://www.dropbox.com/s/cx6brze8m190vc3/wordfile.txt I will give full credit points but everything must be done to the instructions, thanks.

Explanation / Answer

//SECOND DRIVER CLASS POSTED

import java.util.Scanner;

import java.io.*;

import java.util.Collections;

import java.util.ArrayList;

class Driver2

{

public static void main(String args[]) throws IOException

{

ArrayList<String> words[]= new ArrayList[26];

for(int i=0;i<26;i++)

{ words[i]=new ArrayList<String>(); }

String temp="";

int subscript = 0;

//start time

long start=System.currentTimeMillis();

Scanner rw = new Scanner(new FileInputStream("wordfile.txt"));

//get input

while(rw.hasNext())

{

temp=rw.next();

subscript = ((temp.toUpperCase()).charAt(0)) - 'A';

if( subscript >=0 && subscript<=25)

{ words[subscript].add(temp); }


}

rw.close();

//order the lists

for(int i=0;i<26;i++)

{ Collections.sort(words[i]); }

System.out.println("Printing Word Lists");

for(int j=0;j<26;j++)

{

System.out.println("Printing For letter :"+words[j].get(0).toUpperCase().charAt(0));

for(int i=0;i<words[j].size();i++)

{ System.out.println(words[j].get(i)); }

}

//end time

long total=System.currentTimeMillis() - start;

System.out.println("Total time taken: "+total+" milliseconds");

}

}