Java Reference
In-Depth Information
public static void printResults(WordInfo[] table, int head) {
out.printf("\nWords Frequency\n\n");
while (head != -1) {
out.printf("%-15s %2d\n", table[head].word, table[head].freq);
head = table[head].next;
}
} //end printResults
} //end class WordFrequencyHash
class WordInfo {
String word = "";
int freq = 0;
int next = -1;
} //end class WordInfo
Suppose wordFreq.in contains the following:
If you can trust yourself when all men doubt you;
If you can dream - and not make dreams your master;
Using a table size of 13 and MaxWords set to 10, when Program P10.3 was run, it produced the following output in
the file wordFreq.out :
'and' not added to table
'not' not added to table
'make' not added to table
'dreams' not added to table
'your' not added to table
'master' not added to table
Words Frequency
all 1
can 2
doubt 1
dream 1
if 2
men 1
trust 1
when 1
you 3
yourself 1
Search WWH ::




Custom Search