Programming Assignment 1
Due: Feb. 2 before class starts (now Feb. 4 by 5pm)
Description
In this assignment, you are to finish implementing four sequential data
structures: ArrayList
, LinkedList
, Stack
and Queue
. Additionally, you will run experimentation to analyze
time complexity of major operations of these structures to gain an intuitive
feel for the pros and cons of each. You will make a report of your findings.
Program Requirements
- Starting code is found here.
- Put your name at the top of the following files:
ArrayList.java
,LinkedList.java
,Stack.java
,Queue.java
,Timing.java
. - Comments with
TODO
define all necessary tasks to complete the data structures. To aid in completion consult the following items:- Code documentation. Nice output will be found in
Docs
. Openindex.html
in your web browser of choice to see an interactive documentation system. Please note all comments, some tell how the functions should be implemented, what variable names mean, etc. - Textbook implementation of data structures (note these may not match 100%.
- Run the program
Test.java
to run minimal unit tests for the four data structures. Note - these tests are minimal, just because they pass does not imply you implemented the functions 100% correctly. It is simply a guideline to help.
- Code documentation. Nice output will be found in
- You can make all of the code at once with the command
make
, all of the documentation again with the commandmake docs
.
Report Requirements
Your report will include the objective of the assignment, brief description of your implementation, and a discussion of your results (theoretical and experimental). At a minimum your report should include the following organized into sections. Use a technical writing style and typeset your report in LaTeX.
- Introduction. In this section, state or describe the objective of the assignment, a statement about what you learned in the assignment, and a statement summarizing your results.
- Implementation details. Give a brief description of how you implemented the assignment, including what you learned.
- Theoretical analysis.
In this section, you should provide an analysis of and theoretical
discussion (i.e Big-Oh) of the following operations (time only not memory):
- Adding elements to an
ArrayList
and resizing by doubling the size - Adding elements to an
ArrayList
and resizing by incremental size increase - Resizing an
ArrayList
by incremental size increase - Adding elements to a
LinkedList
- Explain why
Stack
is best implemented withArrayList
compared withLinkedList
(specifically from our implementation). - Explain why
Queue
is best implemented withLinkedList
compared withArrayList
(specifically from our implementation).
- Adding elements to an
- Experimental Setup. In this section, you should provide a description of your experiment setup, which includes but is not limited to Machine specification, i.e., processor type, amount of ram, OS, etc.
- Results & Discussion.
In this section, you will compare the performance of the various data
structures. Include and discuss the following plots connecting data back to
theoretical discussions:
- Plot input size vs. time / input size, i.e., amortized time on
ArrayList
add with doubling strategy,ArrayList
add with the incremental strategy, andLinkedList
add. Performn
adds to the end of the list to get time. Put all three in one plot. - Plot input size vs. (time / input size)/expected time for the three operations and determine the Big-Oh constants. Put all three in one plot.
- Plot input size vs. time on
n
randomStack
operations on a stack of sizen
to justify yourStack
implementation being efficient. On the same plot, plot input size vs. time onn
randomQueue
operations on a queue of sizen
to justify yourQueue
implementation being efficient. - Plot input size vs. time/expected time for these two and determine the Big-Oh constants. Put both in one plot.
O(n2)
test the following input sizes:21, 22, ..., 216
. For operations which takeO(n)
orO(1)
test the following input sizes:21, 22, ..., 223
. - Plot input size vs. time / input size, i.e., amortized time on
- Conclusion. Summarize the results found in the experiment.
General Instructions, Turning in assignments, and Grading
General Instructions
- Name each file and program as listed in the instructions (if there are new files to create).
- The top of each file you modify should have a comment of your name.
- Use proper coding style (described more in Grading below)
- Follow turn-in instructions precisely.
- Failure to complete any of these steps will result in a significant loss of points.
Turn in Instructions
Each assignment will be turned in to both Blackboard (soft copy) and in class (hard copy). Assignments are due BEFORE, let me repeat, before class starts. This does not mean five minutes after class starts.
- Soft copy (Online submission)
- Create a compressed
.zip
file of all Java programs needed to compile your program and all input files (if needed) to run your program.- If you do not know how to create a compressed
.zip
file, there is this cool new website you can use to search for instructions by entering"How to create .zip Windows 10"
or"How to create .zip MAC OSX"
for example.
- If you do not know how to create a compressed
- Submit
.zip
file on Blackboard by the stated due date and time. - Submit a
.pdf
file on Blackboard of your report by the stated due date and time. This will be a separate turnin from the code.
- Create a compressed
- Hard copy (In-class submission)
- The first page of your hard copy must be a signed coverpage.
- Next put the programs (only the ones you wrote code in) in order as
described in the description.
- If you do not know how to print a java file, there is this cool
new website you can use to
search for instructions by entering
"How to open and print .java file Windows 10"
or"How to open and print .java file MAC OSX"
for example. In combination with this, you may have to consult University of Richmond webpages to learn how to use campus printers. I recommend printing directly from sublime text editor on University computers (has printing feature enabled) and will print with syntax-highlighting (colors).
- If you do not know how to print a java file, there is this cool
new website you can use to
search for instructions by entering
- Staple all pages together.
- Turn in packet before class begins.
- With a separate signed coverpage print out and turn in your report.
- I reserve the right to assign a 0 to any assignment failing to comply with these instructions. Even for something as small as a missing staple.
Points
- Each assignment is graded out of 100 points (not including bonus). 50 points for the report and 50 points for the code.
- Criteria and point distribution
- If the code is not named precisely or does not compile, -75% of the code.
- If the code does not generate the correct output, -50% of the code.
- Following instructions and algorithm used to solve, 25% of the code. Following instructions is extremely important in computer science, train yourself to think like a computer. There are many ways to solve a problem, some may be better or worse than others.
- Stylistic elements of written code,
25% of the code. Style includes (but is not
limited to):
- Descriptive comments on intent and purpose of code
- Descriptive and consistant naming conventions
- Indenting properly (after an opening brace, tab right by 1 indent; after a closing brace, tab left by 1 indent)
- Consistent spacing
- Consistent bracket placement (same line or on new line)
- Avoiding code duplication
- Content of written report, 80% of the report.
- Clarity and style of written report, 20% of the report.
- If there are any discrepencies in grades please see the instructor during his office hours or by appointment (do not discuss with the lab assistants or graders).