Computer Science 501
Data Structures and Algorithm Analysis
Fall 2014, The College of Saint Rose
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.
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 lecture assignment and 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.
Lecture Assignment Questions
We will usually discuss these questions at the start of class on the lab due date, so no credit can be earned for late submissions of lecture assignment questions.
Given a set of data which is modified periodically and printed in order periodically, describe briefly the circumstances (relative frequency of modifications and printouts) where each of the above three approaches might be beneficial. (5 points)
Practice Program
Programming Assignment
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 (the compareTo method of Comparable objects).
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 instance variables are needed? Do you plan to store the contents of your BestOf in order? Why or why not?
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 is, we will expand it a bit.
Write a program as a main method to 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 need to use an extra class to keep track of information for the Syracuse sequence generation, you can declare a non-public class inside of Syracuse.java that can be used only within that Java file. See the MazeRunner program for examples of these non-public classes.
The intermediate values you will generate can get quite large, so to be safe, use values of type long and Long instead of int and Integer as you generate your sequences.
Expanding and Using BestOf
Now that you have a working BestOf structure, let's use it to compute some things about the mapping data we saw from an earlier lab. You wrote a program that included a Waypoint class that held information from the .gra files linked from /chm/graphs.html.
What you need to do:
Note: for this section, all except the BestOf enhancement will be graded as a practice program.
Submitting
Before 6:00 PM, Tuesday, November 11, 2014, submit your lab for grading. There are two things you need to do to complete the submission: (i) Copy your file with the answers to the lecture assignment and 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. (ii) Upload a copy of your lab (a .7z or .zip file containing your project directory) using Submission Box under assignment "Lab9".
Grading
This assignment is worth 80 points, which are distributed as follows:
> Feature | Value | Score |
LA Question 1 (10.10) | 2 | |
LA Question 2 (10.12) | 3 | |
LA Question 3 (ordered structure options) | 5 | |
SyracuseSeq.java correctness | 6 | |
Basic BestOf correctness (no Comparators) | 15 | |
BestOf test(s) in main method | 2 | |
Syracuse main method correctness | 7 | |
BestOf/Syracuse program design | 3 | |
BestOf/Syracuse program style | 3 | |
BestOf/Syracuse program documentation | 5 | |
Question 1 (thought question 1) | 2 | |
Question 2 (thought question 2) | 3 | |
Question 3 (top 25 numbers) | 2 | |
Question 3 (top 25 sequence lengths) | 2 | |
BestOf using Comparators | 5 | |
Waypoint that implements Comparable | 2 | |
6 Waypoint Comparators | 6 | |
WaypointBest correctness | 7 | |
Total | 80 | |