CSIS 3103 - Assignment 5 : Maps and Sorting
Fall 2010


You can work in pairs on this assignment.

Goals:

Problem Description:

See the descriptions of Programming Projects 2 - 4 on p. 416 that involve processing a large text file by counting the frequency of the words occurring in the file and displaying the results.

The contents of the text file needs to be broken up into words and the frequency of each word counted. The word/frequency pairs will be the elements of a HashMap or TreeMap.

Part 1

Write a program to implement Project 3. from the previous program. It is only necessary to sort by keys in this exercise.

Part 2

You can copy and paste most of the code from Part 1 for reading the file and building the Map. To complete Project 2 using the Java API classes mentioned (and several not mentioned), it is necessary to study the documentation, starting with HashMap in order to know which methods to use and how to use them.

Once the text file has been processed, output the contents of the HashMap.Then obtain a set view of the HashMap and store its contents in an array of Objects. The Arrays class has a sort method that can be used to accomplish the sorting as described. But in order to do this, custom Comparator classes will be needed. Be careful here as some rather complicated type casting will be needed to get the compiler to match types properly. Similar type casting will be needed to output the elements in the sorted array. The sorting by words should ignore case.

Part 3

Once all requirements of Project 2 are working, save a copy of the program and modify to include a list of line numbers for each word as described in Project 4.

Submissions:

Submit the .java files for your project.