Programming Assignment FAQ |
For course policies regarding submission, lateness, grading, and collaboration, see the Assignments page.
There is no need to mark (and unmark) the checkbox if you are submitting before the deadline.
PercolationStats.java
to receive feedback on Percolation.java
,
but you must submit
Percolation.java
to receive feedback on PercolationStats.java
.
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.
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).
Example 1:
This code can be written as:if (isTrue) doA(); doB(); doC(); doD(); } else { doB(); doC(); doD(); }
if (isTrue) doA(); doB(); doC(); doB();
Example 2:
This code can be written as:doA(); doB(); doC(); doD(); while (isTrue) { doA(); doB(); doC(); doD(); }
You can also declare a functiondo { doA(); doB(); doC(); doD(); } while (isTrue);
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.
readme.txt
file.
This header must appear at the very beginning of each Java file and follow the formatting above (e.g., the first line consists of the forward slash character, followed by an asterisk, then a space, then 77 asterisks). Note the space on the first line; this makes it a block comment, not a Javadoc comment. You may add additional information after the description section of the header (such as instructions for compiling, executing, and listing any dependencies)./* ***************************************************************************** * Name: Alan Turing * NetID: aturing * Precept: P00 * * 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. **************************************************************************** */
It is identical to the header for Java files, except that no description is required./* ***************************************************************************** * Name: Alan Turing * NetID: aturing * Precept: P00 * * Partner Name: Ada Lovelace * Partner NetID: alovelace * Partner Precept: P00 **************************************************************************** */
algs4.jar
to your Java classpath.
Arrays.sort()
,
java.util.LinkedList
, java.util.ArrayList
, java.util.TreeMap
, and
java.util.HashMap
?java.lang
such as Math.sqrt()
and Integer.parseInt()
.
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.