Lab Assignment 1.1: Phase 1: Sorting Earthquake Data
Lab Assignment 1.1: Phase 1: Sorting Earthquake Data
Data Structures
Lab Assignment 1.1: Phase 1: Sorting Earthquake Data
Introduction EarthquakeRecord objects yet exist. The file processing reads
one single line of text at a time, and sends that single line of
This lab activity involves more detailed work which will split text to the EarthquakeRecord constructor. The constructor
into three sequenced lab assignments. These three phases
parses the raw text into data-typed fields and returns a
will span three weeks of lab periods. I will publish separate
reference to the newly created object (and of course, a
requirements for each of the 3 phases. Each week, I will reference is really the location information for the newly
expect to see the results of the current phase. created object). That reference value is then stored in the
In phase 1, you will: next available element in the array.
• Load 157,015 earthquake records from a 20 File processing continues until all data has been parsed into
megabyte file. The resulting 157,015 the tens of thousands of EarthquakeRecord objects.
EarthquakeRecord objects will all exist as
independent objects, but be managed using an array Step 1: Build Existing Code
of references. This coding is already implemented. To prove that it works, try first running it in the non-Debug
You need only capture the required .java files and mode. On my machine, in the non-Debug mode, it takes less
the data file; then build a project and run. than 1 second to read and parse the 20MB of data. In the
• Create three additional arrays of references to the Debug mode, it takes closer to 10 times as long: about 8
same set of EarthquakeRecord objects. seconds on my computer.
• Sort each of those three new arrays, using a To prove that the original code does work, I suggest setting a
different sort sequence. To do this, you will use the breakpoint and inspecting the data after file processing has
Arrays.sort() algorithm along with suitable completed. Note the diagram below:
Comparator objects.
In subsequent phases, you will implement a recursive Merge
Sort algorithm to sort the data set on at least three different
key fields . . . but that will come next week.
Submission Requirements
This is only phase 1, so I do not need to see a complete set of
documentation. I will perform a quick review of your working
code and provide comments that will assist in the completion
of phase 2.
Completed code will be worth up to 3 points. (Typically, a full
Lab Assignment is worth 10 points, since it also includes more
documentation and a greater volume of programming.)