Programming Assignment FAQ

General

What’s the difference between the assignment and the checklist? The assignment provides the programming assignment specification; the checklist provides clarifications, test data, and hints that might be helpful in completing the assignment.

Where can I find the course policies regarding submission, lateness, grading, and collaboration? The Assignments page.

I would like to receive help from the course staff. Where can I find the schedules? Piazza is ideal for short technical questions; office hours are best for longer or more conceptual questions; the lab is great for help with debugging. Here is the office hour schedule; here is the lab TA schedule.

Submission

Can I submit assignments via email, hardcopy, or Snapchat? No, you must submit all assignments via Dropbox.

What’s Dropbox? In this course, it means the web-based system that you will use to submit assignments. (The system predates the file-hosting company with the same name.) You will need to login using your OIT NetID and password.

How do I successfully submit an assignment? Here is a short list of things to do:

Can I fix my code and resubmit? Absolutely. There is no penalty for resubmitting files prior to the deadline.

How do I submit an assignment after the deadline? You must mark the checkbox in Dropbox that indicates that your work is incomplete. (Otherwise we will grade whatever is there at the time of grading.) When you are ready to have the assignment graded, unmark the checkbox.

I will be submitting late checkbox
There is no need to mark (and unmark) the checkbox if you are submitting before the deadline.

When I submit, the autograder tells me that I have only 2 checks remaining. Why? In COS 226, there is a limit on the number of times that you may click the Check All Submitted Files button before the Correctness, Memory, and Timing tests are disabled. This policy is intended to enable timely and constructive feedback on your work while you are programming (while, at the same time, discouraging you from relying on the autograder as your exclusive debugging tool). Please review the submission policy.

How many checks do I get if I work with a partner? You and you partner have a total of 10. For example, one partner may submit 7 times and the other may submit 3 times before the Correctness, Memory, and Timing tests are disabled.

On assignments that allow partnering, how do my partner and I submit? One partner submits all of the required files and a full readme.txt file; the other partner submits nothing (and makes sure everything is unsubmitted before the deadline).

When I submit, my browser displays a dialog like the following. What should I do?

      Dropbox taking longer than usual

Click OK to let the autograder continue—sometimes the autograder needs more time than your browser deems appropriate. Whether or not you click OK or Cancel, it counts against your limit of 10 checks.

When I submit, the autograder reports the error “Process took too long and was killed (output may be truncated).” What could cause this? This usually means that the autograder could not complete in the allocated amount of time. The most common cause is a serious performance bug. Another possibility is that your program produces an enormous amount of output, perhaps because you left in a debugging statement. It counts against your limit of 10 checks.

Check All Submitted Files

What exactly does the Check All Submitted Files button in Dropbox do? It compiles and executes your program on the inputs specified in the assignment specification. It also runs three static code analysis tools—Findbugs, PMD, and Checkstyle—that automatically identify common bug patterns and style issues.

Must I submit all of the required files to receive feedback? Yes. However, you may submit a “stub” for some of the files——that is, implement each method to do nothing except return a value of the requisite type.

What should the output look like, if there are no errors or warnings? Here is an example. If you don’t understand an error message, ask on Piazza.

I receive various compiler errors and warnings. What does this mean? Your programs should compile cleanly, with no errors or warnings. There is one exception to this rule (on Assignment 2), where a “generic-array creation” warning is permitted.

I receive various “FAILED” messages in the correctness, timing, or memory tests. What does this mean? Your program does not meet the assignment specifications on the tested inputs. Failing any of these tests will likely lead to a deduction. (Passing all of these tests is a good sign, but does not guarantee that your program is 100% correct; we run additional tests when grading.)

I receive various Findbugs warnings. What does this mean? Findbugs is a program that looks for common bug patterns in your code. You should treat anything it reports as an error (though, occasionally there are false positives). The autograder uses Findbugs 3.0.1 and the configuration file findbugs-lift.xml. It also uses the fb-contrib plugin, which detects additional bug patterns.

I receive various PMD warnings. What does this mean? PMD is a program that looks for common bug patterns in your code. The autograder uses PMD 5.8.1 and the configuration file pmd-lift.xml.

I receive various Checkstyle warnings. What does this mean? Checkstyle is a program that looks for common style issues in your program. The appearance of a warning message does not necessarily lead to a deduction (and, in some cases, it does not even indicate an error). You should pay particular attention to the custom checks, which are specialized to each program. The autograder uses Checkstyle 8.5 and the configuration file checkstyle-cos226.xml.

I receive an “Incorrect COS 226 header format” error. How do I fix this? At the top of each Java file, include a header in the proper format.

What is the proper format for the header for Java programs? Here is an example for an assignment with no partner.

/******************************************************************************
 *  Name:    Kevin Wayne
 *  NetID:   wayne
 *  Precept: P01
 *
 *  Partner Name:    N/A
 *  Partner NetID:   N/A
 *  Partner Precept: N/A
 * 
 *  Description:  Model an n-by-n percolation system using the union-find
 *                data structure.
 ******************************************************************************/
The header must appear at the very beginning of the Java file and follow the formatting above (e.g., the first line consists of the forward slash character, followed by 78 asterisks). You are free to add additional information after the description section of the header (such as instructions for compiling, executing, and listing any dependencies) but this is not required.

How strictly must I adhere to the formatting requirements? You should strive to match it exactly. We recommend cut-and-pasting the above template. However, if you use only 75 asterisks on the first line (instead of 78), that will be accepted.

What is the format of the header for the readme.txt file? It is the same as for Java programs, except no description is required.

/******************************************************************************
 *  Name:    Robert Sedgewick
 *  NetID:   rs
 *  Precept: P02
 *
 *  Partner Name:    Kevin Wayne
 *  Partner NetID:   wayne
 *  Partner Precept: P01
 ******************************************************************************/

May I use non-ASCII characters in the header? No, please use only ASCII characters.

Java

I haven’t programmed in Java in a while. Which material do I need to remember? For a review of our Java programming model (including our input and output libraries), read Sections 1.1 and 1.2 of Algorithms, 4th Edition.

Which Java programming environment should I use? For simplicity, we recommend the lightweight IDE DrJava along with the command line. If you use our Mac OS X or Windows installer, then everything should be configured and ready to go. If you prefer to use another environment (such as Eclipse or Sublime), that’s perfectly fine—be sure that you can use command-line arguments; read from standard input, redirect standard input and output; and add algs4.jar to your Java classpath.

What are the input and output libraries? We have designed a set of easy-to-use Java libraries in algs4.jar (similar to the one from COS 126) for input and output. You are required to use these in this course. Here are the APIs.

Where can I find the Java code for the algorithms and data structures from lecture and the textbook? They are in algs4.jar. Here are the APIs.

Can I use various Java libraries in this assignment, such as Arrays.sort(), java.util.LinkedList, java.util.ArrayList, java.util.TreeMap, and java.util.HashMap? In general, do not use any Java library until we have implemented equivalent versions in lecture. Once we have introduced them in lecture, you are free to use either the Java library version or our equivalent. You are permitted to use common functions in java.lang such as Math.sqrt() and Integer.parseInt().

How do I throw a specific exception, such as java.lang.IllegalArgumentException? Use a throw statement like the following:

if (row < 0 || row >= n) {
    throw new IllegalArgumentException("row index is out of bounds: " + row);
}
While you are required to throw exceptions using throw statements as specified, you should not catch exceptions with try-catch statements—this will interfere with our grading scripts.

Style

How should I compose my code? Here are some recommended style guidelines. Below are some that are particularly important (and for which you risk losing points if you ignore).

How should I format and comment my code? Below are some that are particularly important (and for which you risk losing points if you ignore).

Memory Analysis

What’s the difference between tilde notation and order of growth notation? Both tilde notation and order of growth notation discard lower order terms. Tilde notation includes the coefficient of the leading term; order of growth notation discards the coefficient of the leading term. You risk losing points for including lower order terms, failing to include the leading coefficient with tilde notation, and including the leading coefficient with order of growth notation.

How do I calculate the memory used by an object? Use the memory model described in the textbook and lecture slides.

If an object references other objects, should I count the memory of the objects referenced? In general, you should count all memory unless instructed to do otherwise.

Timing Analysis

When I’m told to find a formula using tilde notation for the running time, can I assume that the running time obeys a power law (e.g. a nb)? Yes. If you really want to go above and beyond, you can try to use fancier fitting techniques, but please explain your methodology, as it’s very easy to make mistakes when trying to fit functions like n log n.

I get an exponent of 2.1, but I’m expecting it to be 2. What should I put down as an answer? You should report the value as 2.1. Feel free to explain why you think it should be 2.

Different data points are giving me different exponents! What do I do? It’s mostly correct to say that you should use the largest data point you can. Answers given with large data points will be considered correct.

How many data points do I need to analyze the run time of my program? At a minimum, you should use 5. You risk losing points if you use fewer than 5 or if the data points that you use are for too small a value of n (e.g., take only a fraction of a second).

How do I make the data collection process less tedious? We recommend writing a program that prints the tables for you. You can even instrument it to print the log ratios! The nice thing about this is that you can reuse this code for future assignments (with some minor tweaking). For example, see DoublingRatio.java. Feel free to copy, paste, and modify this code.

When the readme.txt asks to give the running time in seconds, can I derive the formula through mathematical analysis? No. While one could make a case for trying to theoretically derive the order of growth of an algorithm, you’d have no hope of finding the leading coefficient because it depends on the machine on which it is running.

However, you are welcome to make comments about the order of growth that you’re expecting based on your understanding of theory. A mismatch with your empirical results might indicate a bug in your code, a misunderstanding of theory, a warm and fuzzy feeling that there is a missing log factor in the empirical result, or a demonstration that n is not large enough for asymptotic behavior to be observed (this is particularly true if the log ratio has not settled down).