Computer Science 226
Algorithms and Data Structures
Fall 2013

Course Information | Assignments | Exercises | Lectures | Exams | Precepts | Study Guide | Booksite


Below are links to the programming assignments. For each assignment, the assignment entry contains the programming assignment specification; the checklist entry points to clarifications, test data, and hints that might be helpful in completing the assignment; the submit entry links to the electronic submission system; and the collaboration entry specifies the collaboration policy. Do not begin the assignment before reading this entire page which includes assignment policy. Once the assignment moves above the "Assignments below have not yet been updated for Fall 2013" part of the table, no significant changes will be made.

NEW: Readme Guide. The readme guide provides answers to common questions about readme file and also provides a list of tips and common mistakes.

1 Wed 9/18 Percolation checklist submitindividual
2 Wed 9/25 Deques and Randomized Queues checklist submitpartner
3 Wed 10/2 Pattern Recognition checklist submitpartner
4 Wed 10/9 8 Puzzle checklist submitpartner
5 Wed 11/6 Kd-Trees checklist submitpartner
6 Wed 11/13 WordNet checklist submitpartner
7 Tue 11/26 Seam Carving checklist submitpartner
8 Wed 12/11 Autocomplete checklist submitpartner

Submission policy.  You must submit your solutions electronically via the Dropbox submission system. You will need to type your Princeton netID and password for authentication. Be sure to type your name, login, and precept number at the top of every file you submit. Also be sure to click the Check All Submitted Files button to make sure that you have submitted all of the required files and that they compile cleanly. If you do not follow these directions, you will lose a substantial number of points.

The Check All Submitted Files button now requires that you have a header with the above information. For assignments where a partner is allowed you are required to include your partner information in the header (even if you do not have a partner). Each time you click this button, a counter is incremented. You are allowed to click this button (not including invalid header attempts) up to 10 times. After that it will be disabled until the next assignment. Any problems, contact Maia Ginsburg.

You can resubmit and unsubmit files as needed up until the submission deadline. However, once the submission deadline passes, you should not resubmit or unsubmit files: if you wish to submit an assignment late, be sure that your submission directory is empty from the deadline until you are ready to submit all of your files for that assignment. Any files submitted at grading time will be graded as is.

Lateness policy.   Programming assignments are due at 11pm on the date specified, with a 3-hour grace period. Late assignments are assessed a 4-point penalty per day or partial day: 0–3 hours late (no penalty), 3–27 hours late (4 points), 27–51 hours late (8 points), and so forth. Your first 16 lateness points are automatically waived. No additional lateness points will be waived without the recommendation of a Dean or a letter from McCosh Health Center.

Grading policy.  Your code will be graded for correctness, efficiency, clarity, and style (including comments). It is your responsibility to describe how you have completed the assignment in the submission, not ours to glean this information from your code. Partial credit is available for a partially complete assignment; just explain the situation in your readme.txt file.

Coursera policy.   You are not permitted to use the Coursera code submission system. Countermeasures (not specified) are in place, and violations will be referred to the Committee on Discipline.

Collaboration Policy

In this course you may receive help only in the ways described below. You must acknowledge all help received in the readme.txt file for that week's assignment.

Your Work

When we talk about work, this includes code, comments, readme files, or anything else you create for this course.

You must individually compose all of your own work during the term.

Your work must never be shown or communicated to anyone who is taking COS 226 now or who might take COS 226 in the future.

You must never place your work in any public location (including websites, leaving printouts in a classroom, etc). Password-protect your laptop if left unattended.

You must never give a copy of your work to anyone, except for course staff.

The rules above apply both to finished and unfinished work. They continue to apply even after this semester is over.

In some assignments, you are given some code to begin with. Like other course materials, you are allowed to read and discuss the original code with other students, to figure out what it does and how it works. But once you make a change to the code, it becomes your work and the rules above apply to it.

Citing and Allowable References

Copying or adapting work that is not yours is only permitted if it comes from the course materials. If you do so, you must cite what you used.

Reading someone else's solutions (or partial solutions) for assignments (or anything similar to any COS 226 assignment) is not allowed.

Getting Help

Ask for help — that is why the course staff members are here! Utilize office hours, the lab TA hours, and Piazza. E-mail your preceptor or make an appointment with them. Avoid procrastinating, since getting help requires extra time.

If you don't know where to start on an assignment, try beginning with the "Possible Progress Steps" on the checklist, and review the related exercises on the Precepts page.

Peer/Piazza Discussion

You must individually compose your solutions for the course, but some common concerns may be discussed with other current students, or publicly on Piazza. Because of the rules above, these discussions must be kept at a general level, without sharing code or other work about assignments. For example, you may ask about:

Don't let someone be too helpful: it is not allowed for someone to lead you step-by-step through any part of an assignment.

Help From COS 226 Graduates

Anyone who successfully completed COS 226 in a previous term is allowed to assist you in the following ways, similar to what a lab TA would do:

Anybody else (e.g. friends, family, tutors) may help you under these same conditions (provided they are not taking COS 226 now and never will in the future).

Piazza Etiquette

Piazza works best for individual questions with well-defined answers.

Use public posts when your question can be asked in a general way, without sharing code or other work about assignments. Other students may answer it, or they may benefit from seeing the discussion.

If you have a question that involves your code or other specific details, then use office hours, the lab, or this two-step approach:

  1. Post a public Piazza question that describes your problem in general terms;
  2. if the answer does not help, post your specific question privately. If your code is involved, upload it to the Dropbox, and mention this.

Never post assignment code to Piazza, even privately; the Dropbox is easier for course staff to use.


On programming assignments designated as partner, the collaboration policy is relaxed to permit working with one partner. For partnering, both students work together (in the same room) and discuss, write, debug, test, analyze, document, and submit all elements of the assignment. In this case, only one partner (with the other partner present) submits the code and readme.txt; the other partner submits only an abbrievated readme.txt that contains both partners' names, logins, and precepts. The names, logins, and precept numbers of both partners should appear at the top of every submitted file. Both partners are responsible for understanding all parts of the submitted assignment and receive the same grade.

If two students begin working on an assignment as partners and cannot complete it together, at least one student must contact the lead preceptor to request a partnership dissolution.

Extra Credit

Some assignments have optional Extra Credit parts. These are for people who found the assignment straightforward and want an extra challenge.

Don't rely on them to "bring up" your grade, as we only give them a small discretionary value at end of term for people close to a grade boundary.

Extra credit has stricter collaboration rules.

Taking COS 226 Again

If you took COS 226 (or part of it) before,


If anything about these policies is unclear during the course, please consult us and ask for clarification. Princeton's Rights, Rules, Responsibilities handbook asserts:

The only adequate defense for a student accused of an academic violation is that the work in question does not, in fact, constitute a violation. Neither the defense that the student was ignorant of the regulations concerning academic violations nor the defense that the student was under pressure at the time the violation was committed is considered an adequate defense.

We use software to compare student submissions. Pairs that are identified as similar are inspected manually by course staff.

Violators of the course policy will be referred to the Committee on Discipline for review. If found responsible, you will receive an F as a course grade plus whatever disciplinary action the Committee imposes. The typical penalty they impose for plagiarism is suspension from the University for one year.

Computing laboratory.   The Friend 017 computing laboratory is open 24 hours a day. It contains iMacs which can run either OS X or Windows; alternatively, you can bring your own laptop. Most evenings, the lab is staffed with undergraduate lab TAs, who can answer general computer-related questions and assist in debugging. If you have specialized questions regarding the course materials or programming assignments, see your preceptor or instructor.

Important note.   Please do not publish solutions to programming assignments in a way that could compromise their utility as pedagogical tools. At Princeton, this is a violation of the basic rights, rules and responsibilities of members of the university community.