[UW Logo]

CS 341: Algorithms, Fall 2016

Crosslisted as CM 339.

David R. Cheriton School of Computer Science

Contents: General Info, Organization, Announcements, Resources, Assignments, Lectures, University Policies

General Information


Instructors: Jeffrey Shallit, DC3134, x34804, (sorry, but to foil spammers, that's not a cut-and-pastable link)

Office hours: Mondays, 11 AM - Noon; Wednesdays, Noon - 1 PM, or by appointment, or just stop by when my office door is open. Scheduled office hours begin Monday, September 12.

In addition I will hold "virtual office hours" every Wednesday night from 9 PM to 10 PM via AOL Instant Messenger. I use the id "CS462Prof". This is a good way to get last-minute help (and even anonymously, if you so choose).

Tim Smith, DC 3124, x33319, timsmith@uwaterloo.ca

Office hours: 4:30-6:30 PM Tuesdays


Time and Place:

First class is THURSDAY, SEPTEMBER 8!


Many students find CS 341 a challenging course. But there is a relatively simple path to success. Here's how to do well in the course:

First, come to all the classes. Students who fail the course almost always have poor attendance.

Next, do all the assignments. Students who fail the course almost always do so because they hand in only a few of the 12 homework assignments. Doing the assignments exercises your neurons so that you are in the mode of thinking about the course material -- this will also help you understand better in class, and do well in the midterm and final.

Finally, allocate 3 hours per week to go over the course notes, try the suggested exercises, and read the assigned sections of the textbook. Circle anything you don't understand well and see a TA or instructor to clear up any difficulties. Do as many supplementary exercises as possible!

If you do all these, we guarantee you will pass the course.

Credit: Assignments 36%, Midterm 20%, Final 44%. Your final mark is determined from your marks on these and nothing else. In particular, there is no requirement to pass the final in order to pass the course.


Turn in your assignments, in pdf format, via LEARN. You should prepare your solutions using a document preparation system such as LaTeX or Microsoft word. Please do not write solutions by hand and scan them in, unless your handwriting is really superb. For figures, feel free to sketch by hand and scan in the results.

Assignments will be given out on Thursdays and will be due at 5 PM on Thursdays, according to the following schedule:

Assignment number	Handed out	Due             Marker
	1		September 8 	September 15	Shayan and Vedat
	2		September 15	September 22	Q1 Vedat; Q2 Shayan; Q3,Q4 Hong
	3		September 22	September 29 	Q1 Vedat; Q2 Hong; Q3 Shayan
	4		September 29	October 6       Q1 Shayan; Q2 Vedat; Q3-Q6 Hong     
	5		September 29	October 13	Hassan
	6		October 13	October 20 	Q1 & Q4, Kirsten; Q2 & Q3, Hong

        7		October 20	October 27	Q1 & Q2, Vedat; Q3 & Q4, Shayan
	8		October 27	November 3	Q1 Hassan, Q2-Q4 Hong
	9		November 3 	November 10	Q1 Hong; Q2 Kirsten; Q3 Vedat
	10		November 10	November 17	Q1 Kirsten; Q2 Hong; Q3 Shayan
	11		November 17	November 24 	Q1 & Q3, Hassan; Q2 Kirsten
	12		November 24	December 1	Q1 Shayan; Q2 Hong; Q3 Vedat

The work you hand in must be your own. Acknowledge any sources you have used. Unless specified otherwise, you can always use any result from the textbook, notes, or previous course, just by citing it.

Since solutions are posted almost immediately online, late assignments will not be accepted under any circumstances. No extensions!

In all assignments and exams, unless otherwise directed, you are expected to justify any claims that you make. The level of explanation we generally expect is "enough to convince a skeptical TA". Usually this means that a complete formal proof from first principles is not needed (unless we say so). Furthermore, since this course is essentially all about efficient use of time and space, strive to make your solutions as efficient as possible. Solutions that are technically correct, but extremely wasteful in terms of time and space, will not receive full credit.

This is not a software engineering course. We will basically never worry about trivial edge cases (such as the case of empty input), or inputs that do not match our specifications. We will not take off marks for code that doesn't handle edge cases correctly (unless they are crucial to correctness or analysis). In your solutions, there is no need to spend any time dealing with these (unless you want to).

The default in this course is that all numbers we deal with are integers. If there are exceptions, we'll let you know.

Some of the algorithms we will discuss in this class have multiple versions and variations. All assignment and exam questions deal with the versions we present. If you choose to learn the material from other sources, such as Wikipedia, rather than from the course notes and textbook, be aware that sometimes these minor differences may affect the answers.

If you have a question or complaint about how your assignment or exam was marked, please start by contacting the TA who marked your assignment or exam. This can be determined either by consulting the initials written on your assignment, or by looking on the course home page. Make arrangements to see this TA to discuss your assignment. You must make initial contact with the TA within one week from the day your assignment is returned.

If you do not get satisfaction from the person who marked your assignment, or if you cannot determine who did, please contact the head TA, Hong Zhou.

Finally, if you do not get satisfaction from either of those two people, contact the professor of your section.

Your single lowest mark out of the 12 assignments will be thrown out*, so you can (if you choose) not hand in 1 of the 12 assignments.

* This does not apply if you were caught cheating on an assignment.

On the last day of classes, a prize will be given to the student in each section with the highest average so far.

Algorithmic Challenges

Compiled from the lecture notes, solve any of these challenges and get an automatic 100 in the course!


See this page for additional readings of interest for each lecture.


We will not use the newsgroup uw.cs.cs341. Instead we will use Piazza for all course announcements. So you should enroll yourself at your earliest convenience. During Piazza discussions, please do not reveal the solutions to the assignments by requesting or offering extremely detailed advice. We'll delete comments that reveal too much. Violations can result in academic sanctions.

Similarly, do not solicit hints or provide hints about how to solve the homework problems on other bulletin boards, such as Facebook. Violations can result in academic sanctions.

Marks will be available through LEARN.


Textbook: [CLRS] Cormen, Leiserson, Rivest, and Stein, Introduction to Algorithms (3rd ed.), MIT Press, 2009 (QA76.6 .C662 2009).

Additional reference: [DPV], Dasgupta, Papadimitriou, Vazirani, Algorithms, available here.

Additional books on DC library reserve for 3-hour loan:


We are not following the text exactly, so the lecture notes should be your primary source. These are preliminary notes and might be revised as the term progresses, so check back.


Plagiarism is a serious offence. The penalty for the first offence is 0 on the assignment and a further 5 marks off the final course grade. To avoid plagiarism accusations, do not copy other people's work, and cite all references that you use. If you work with others, only discuss general aspects of the course material, not specific solutions. Write up the solutions yourself, not in groups.

University Policies (University required text)

Academic Integrity:

In order to maintain a culture of academic integrity, members of the University of Waterloo community are expected to promote honesty, trust, fairness, respect and responsibility. All members of the UW community are expected to hold to the highest standard of academic integrity in their studies, teaching, and research. The Office of Academic Integrity's website ( http://www.uwaterloo.ca/academicintegrity) contains detailed information on UW policy for students and faculty. This site explains why academic integrity is important and how students can avoid academic misconduct. It also identifies resources available on campus for students and faculty to help achieve academic integrity in - and out - of the classroom.


A student who believes that a decision affecting some aspect of his/her university life has been unfair or unreasonable may have grounds for initiating a grievance. Read Policy 70 - Student Petitions and Grievances, Section 4, http://www.adm.uwaterloo.ca/infosec/Policies/policy70.htm .


A student is expected to know what constitutes academic integrity, to avoid committing academic offenses, and to take responsibility for his/her actions. A student who is unsure whether an action constitutes an offense, or who needs help in learning how to avoid offenses (e.g., plagiarism, cheating) or about "rules" for group work/collaboration should seek guidance from the course professor, academic advisor, or the Undergraduate Associate Dean. When misconduct has been found to have occurred, disciplinary penalties will be imposed under Policy 71 - Student Discipline. For information on categories of offenses and types of penalties, students should refer to Policy 71 - Student Discipline, http://www.adm.uwaterloo.ca/infosec/Policies/policy71.htm.

Avoiding Academic Offenses:

Most students are unaware of the line between acceptable and unacceptable academic behaviour, especially when discussing assignments with classmates and using the work of other students. For information on commonly misunderstood academic offenses and how to avoid them, students should refer to the Faculty of Mathematics Cheating and Student Academic Discipline Policy, https://uwaterloo.ca/math/current-undergraduates/regulations-and-procedures/cheating-and-student-academic-discipline-guidelines.


A student may appeal the finding and/or penalty in a decision made under Policy 70 - Student Petitions and Grievances (other than regarding a petition) or Policy 71 - Student Discipline if a ground for an appeal can be established. Read Policy 72 - Student Appeals, http://www.adm.uwaterloo.ca/infosec/Policies/policy72.htm .

Here is a page we are required to give you, even though all the same info is above.