Computer Science 210
Data Structures
Fall 2016, Siena College
For this lab, you will be implementing an interesting ordered structure and using it in a number of contexts.
You may work alone or in a group of 2 or 3 on this lab. Only one submission per group is needed.
While this lab is not due until right before you leave for Thanksgiving break, you should try to get as much as possible done this coming week.
Getting Set Up
To get your BlueJ environment set up for this week's lab assignment, start BlueJ and choose "New Project" from the "Project" menu. Navigate to your folder for this course and choose the name "Lab9" (no spaces) for the project.
Create a document where you will record your answers to the lab questions. If you use plain text, call it "lab9.txt". If it's a Word document, you can call it whatever you'd like, but when you submit, be sure you convert it to a PDF document "lab9.pdf" before you submit it.
Practice Program
Finding the "Best Of"
The remaining tasks will be graded as a programming assignment.
The first part of your programming assignment is to complete the laboratory in Section 11.4 of Bailey - computing the "Best Of" a collection of values by some metric. Initially, the metric will be determined by the compareTo method of the Comparable objects we we place into the BestOf data structure.
First, carefully read the lab description in the text. Before you start coding, think carefully about the BestOf class. What does it extend and/or implement? What will you use for your BestOf's internal data representation? Based on that data representation, what instance variables are needed? Do you plan to store the contents of your BestOf in order at all times or sort them as needed? Why or why not? Do not start coding until you are confident in your answers to these questions.
Your BestOf's main method should run one or more simple test cases for your structure. You may use the one described at the top of p. 276 or devise your own test cases.
Rather than answering thought question 3 as written, we will extend it a bit.
Write a program as a main method in a class Syracuse in a file Syracuse.java that generates the Syracuse sequences for all starting values from 1 up to n, given as a command-line parameter. Your program should track and report the following:
You should maintain two BestOfs for this program, one responsible for each above the parts above. Should you wish to use an extra class to keep track of information for the Syracuse sequence generation (and that's a Good Idea), you might want to declare a non-public class inside of Syracuse.java that can be used only within that Java file. Class examples SimpleLinkedList and MazeRunner have examples of non-public classes.
The intermediate values you will generate can get quite large, so you should store numbers in variables of type long and Long instead of int and Integer as you generate your sequences.
Working with Travel Mapping Data
Next, you will begin working with some real world data derived from highway systems. You will likely use this same data in other assignments later this semester.
A big advantage of working with this kind of data is that it has a connection to reality, and that we can visualize the data and the results of our manipulations of that data with the Google Maps API. This data is collected by the Travel Mapping (TM) Project (http://tm.teresco.org/). The METAL project has taken the highway data from TM and converted into a format that is more convenient for us to load into a data structure and use. Much more about the project is available at (/metal/, but everything you need to know should be on this sheet.
The Data
The data is in plain text ".tmg" ("Travel Mapping Graph") files which have the following format:
These graph files are linked from http://tm.teresco.org/graphs/. For example, usai.tmg describes the entire U.S. Interstate Highway system. YT-all.tmg describes a much smaller set of roads: the routes in the Yukon. You can download a few individual files, or download a zip file of the entire collection.
If you'd like to see what this data looks like in map form, you can load it into the METAL project's Highway Data Examiner, at /metal/hdx/.
Initially, you will work only with waypoint data and ignore the road segments. Your tasks:
Expanding and Using BestOf
Now let's take your working BestOf structure, enhance it a bit, then use it to compute some information about this mapping data.
What you need to do:
A point of emphasis in this lab is on error checking: if your program expects a command-line parameter that is not provided, your program should not crash with an exception. It should print a meaningful error message.
Submitting
Before 11:30 AM, Friday, December 2, 2016, submit your lab for grading. There are two things to do to complete the submission: (i) Copy your file with the answers to the lab questions into your project directory. Be sure to use the correct file name. If you prepared your answers in Word, export to a PDF file and submit that. and (ii) upload a copy of your lab (a .7z or .zip file containing your project directory) to Blackboard under "Lab9". Don't forget to check your programming assignment programs for compliance with the Style Guide for CSIS 210 Programs
Grading
This assignment is worth 125 points, which are distributed as follows:
> Feature | Value | Score |
SyracuseSeq.java correctness | 6 | |
Basic BestOf correctness (no Comparators) | 15 | |
BestOf test(s) in main method | 2 | |
Question 1 (thought question 1) | 2 | |
Question 2 (thought question 2) | 3 | |
Syracuse main method correctness | 7 | |
Question 3 (top 25 numbers) | 2 | |
Question 4 (top 25 sequence lengths) | 2 | |
Waypoint fields | 3 | |
Waypoint constructor | 3 | |
Waypoint accessors | 3 | |
Waypoint equals | 2 | |
Waypoint toString | 2 | |
WaypointLoader command-line param with error checking | 3 | |
WaypointLoader load waypoints into a Vector | 10 | |
WaypointLoader interactive loop | 6 | |
WaypointLoader print all matching waypoints | 10 | |
Waypoint that implements Comparable | 2 | |
BestOf using Comparators | 5 | |
Waypoint Comparator(s) for 6 criteria | 6 | |
WaypointBest correctness | 7 | |
Program design | 4 | |
Program style | 3 | |
Program documentation | 15 | |
Total | 125 | |