Programming Assignment FAQ


For course policies regarding submission, lateness, grading, and collaboration, see the Assignments page.


Expand All Collapse All


Submission
Can I submit an assignment via email, hardcopy, git, or Snapchat?
No, you must submit all assignments via TigerFile.
How do I successfully submit an assignment?
Here is a short list of things to do:
How do I submit an assignment after the deadline?
We will not grade your assignment until you submit the acknowledgments.txt file. So, when you are read to submit the assignment, simply upload the acknowledgments.txt file and we will know that it is ready to be graded.
On assignments that allow partnering, how do I submit?
First, you must form a group by clicking the green Create Group button in TigerFile. You must do this even if you are working alone—a group of one. If you are working with a partner, add your partner as a group member. Your partner will receive an email with a link to confirm the partnership. Once you have created a group, any group member may submit.
Can I fix my code and resubmit?
Yes. There is no penalty for resubmitting files prior to the deadline. There is, however, a limit on the number of times you can receive autograder feedback using the Check Submitted Files button.
Check Submitted Files
What exactly does the Check Submitted Files button in TigerFile do?
It compiles your code and checks that it conforms to the assignment specifications by running a battery of correctness tests. On some assignments, it also performs memory and timing tests. It also runs three static code analysis tools—Spotbugs, PMD, and Checkstyle—that automatically identify common bug patterns and style issues.
When I submit, TigerFile tells me that I have only two checks remaining. Why?
In COS 226, there is a limit on the number of times that you may click the Check Submitted Files to receive feedback. This policy is intended to enable timely and constructive feedback on your work while you are programming (but discourage you from relying on the autograder as your exclusive debugging tool). Please review the submission policy.
Must I submit all of the required files to receive feedback?
No. The autograder will give feedback on whichever files you submit, provided that they compile. For example, you need not submit PercolationStats.java to receive feedback on Percolation.java, but you must submit Percolation.java to receive feedback on PercolationStats.java.
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 Ed.
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 SpotBugs, PMD, or Checkstyle warnings. What does this mean?
When I submit, the autograder reports the error “Process took too long and was killed (output may be truncated).” What could cause this?
Please report on Ed. 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.
When I click the Check Submitted Files button, I receive a { failed to fetch, NetworkError when attempting to fetch resources } message. How can I fix that?
This is your browser’s way of telling you that you are not connected to the Internet.
I clicked the Check Submitted Files button but { my browser crashed, my computer dropped the network connection, I closed the browser tab containing the results, ... } Can I get the check back?
No. However, if you were charged a check, you should be able to access the results by clicking the Latest Check Submitted Files link.
Testing
Do I have to test my code?

Yes. For some assignments, you will be given very clear instructions on how to implement the test client. In others, you will be asked to implement your own test client that tests the methods you have implemented. Although the autograder tests your code, you are expected to test your code before you use the autograder.

For grading purposes, your test client will satisfy the requirements if it calls every public method in your code at least once in a meaningful way (by printing the return value, for example). For genuinely testing your code, you will often need to do more than that.

What should my program do if the user specifies an invalid input?

In general, professional programmers must write code to carefully check and validate any user input. In this course, however, you may assume that user specifies valid input. For example, you may assume that the command-line arguments to PercolationStats are two integers (and not, say, a string and a double).

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 do I avoid repetitive code?
Whenever you see yourself repeating code, take it as a red flag and consider refactoring. The following are two examples:

Example 1:

    if (isTrue)
        doA();
        doB();
        doC();
        doD();
    } else {
        doB();
        doC();
        doD();
    }
This code can be written as:
    if (isTrue)
        doA();
    doB();
    doC();
    doB();

Example 2:

    doA();
    doB();
    doC();
    doD();
    while (isTrue) {
        doA();
        doB();
        doC();
        doD();
    }
This code can be written as:
    do {
        doA();
        doB();
        doC();
        doD();
    } while (isTrue);
You can also declare a function doAll() (for e.g.) that calls doA(), doB(), doC() and use it as follows:
    doAll();
    while (isTrue)
        doAll();

Always consider using functions to encapsulate repeated code. Avoiding repeated code using functions enhances readability, simplifies debugging and localizes future changes to a single place.

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).
Does the absence of SpotBugs, PMD, and Checkstyle errors guarantee that I will not lose points for style?
Fixing SpotBugs, PMD, and Checkstyle errors is necessary but not sufficient. The following are examples of important style or design issues that are not flagged by any of these tools:
Java
I haven’t programmed in Java in a while. How much Java 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?
We recommend our customized IntelliJ programming environment, for Mac OS X, Windows, and Linux. If you followed our instructions, then everything should be configured and ready to go. If you prefer to use another environment (such as Eclipse or Sublime), that’s 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.
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 an equivalent versions in lecture. Once we have introduced an algorithm in lecture, you are free to use either our version or the Java library equivalent. You are permitted to use common functions in java.lang such as Math.sqrt() and Integer.parseInt().
Memory Analysis
What’s the difference between tilde notation and big Theta notation?
Both tilde notation and big Theta notation discard lower-order terms. Tilde notation includes the coefficient of the leading term; big Theta 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 big Theta notation.
How do I calculate the memory used by an object?
Use the memory model described in the textbook, lecture slides, and booksite.
If an object references other objects, should I count the memory of the referenced objects?
Unless instructed to do otherwise, you should count all memory allocated by the data type itself but not memory allocated by the client of the data type. For example, if a queue is declared as Queue<String> and is implemented as a linked list of nodes, you should count the memory of the Node objects (including references to the String objects) but not the memory of the String objects themselves. The String objects in the queue are allocated by the client of the queue, whereas the Node objects are allocated by the queue itself.
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 running 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 too small (e.g., take only a fraction of a second).
How do I make the data collection process less tedious?
We recommend writing a program. For example, see DoublingRatio.java. Feel free to copy, paste, and modify this code.
When I'm asked to give the running time of my program in seconds using tilde notation, can I derive the formula solely through mathematical analysis?
No. You must perform computational experiments because the leading coefficient in the tilde notation depends on your machine. It’s good practice to also develop a mathematical model and check that the theoretical order of growth matches the one you observe in practice.
Can I lose points for performance even if I pass all of the provided timing tests?
Yes. The autograder in TigerFile reveals only some of the timing tests that we perform when grading your assignment.