CS 341: Algorithms Fall 2023

This course studies the major algorithmic design paradigms and mathematical tools for analyzing the running times of algorithms and detecting computational problems for which no efficient deterministic algorithm. Topics include: basics of analysis of algorithms; general algorithmic paradigms: (i) divide and conquer; (ii) greedy algorithms; (iii) dynamic programming; and (iv) graph algorithms; NP-completeness and its implications; and undecidability.

This course is an in-person course. Although some material (such as slides used in lectures or notes) maybe provided on the webpage, students are expected to attend lectures. The midterm and final exam are also in-person.

In the event that the university suspends in person activity:
• All activities will shift online (and some activities may need to be adjusted/curtailed due to the increased workload of producing video lectures)
• The midterm and final will become take-home exams
Calendar description
Official course description from the course calendar
Handbook description
Longer course description from the Computer Science Undergraduate Handbook

Lecture materials (slides) will be posted here. If you are happy to learn from the slides, that's fine. When you need more details/examples, or if you like a text book format, here are the corresponding sections of the text, CLRS, together with our recommendations for alternative sources available online. For descriptions of the books, see Resources.

Date Topics Slides CLRS Other readings
(* = highly recommended)
Week 1 L1 Sept 7 Introduction & Analyzing Algorithms Trevor: light.1up.pdf light.6up.pdf light.pptx dark.1up.pdf dark.6up.pdf dark.pptx
Rafael: 00 PDF, 01 PDF
1, 2.1, 2.2, 3 * [Skienna] 1, 2
Week 2 L2 Sept 12 Divide-and-conquer I Trevor: light.1up.pdf light.6up.pdf light.pptx dark.1up.pdf dark.6up.pdf dark.pptx
Rafael: PDF
4.1, 4.3, 4.4, 4.5; Optionally CLRS 2.3
L3 Sept 14 Divide-and-conquer II Trevor: light.1up.pdf light.6up.pdf light.pptx dark.1up.pdf dark.6up.pdf dark.pptx
Rafael: PDF
4.2 [DPV] 2
Week 3 L4 Sept 19 Divide-and-conquer III Trevor: light.1up.pdf light.6up.pdf light.pptx dark.1up.pdf dark.6up.pdf dark.pptx
Rafael: PDF
9.3
L5 Sept 21 Greedy I Trevor: light.1up.pdf light.6up.pdf light.pptx dark.1up.pdf dark.6up.pdf dark.pptx
Rafael: PDF
16.1 [Erickson] 4
Week 4 L6 Sept 26 Greedy II Trevor: light.1up.pdf light.6up.pdf light.pptx dark.1up.pdf dark.6up.pdf dark.pptx
Rafael: PDF
16.2
L7 Sept 28 Dynamic Programming I Trevor: light.1up.pdf light.6up.pdf light.pptx dark.1up.pdf dark.6up.pdf dark.pptx
Rafael: PDF
intro of 15, 15.3; CLRS 15.1 Optional [Erickson] 3.1, 3.4
Week 5 L8 Oct 3 Dynamic Programming II Trevor: light.1up.pdf light.6up.pdf light.pptx dark.1up.pdf dark.6up.pdf dark.pptx
Rafael: PDF
[DPV] 6.4
L9 Oct 5 Dynamic Programming III Trevor: light.1up.pdf light.6up.pdf light.pptx dark.1up.pdf dark.6up.pdf dark.pptx
Rafael: PDF
15.4
Week 7 L10 Oct 17 Graph Algorithms I (intro and BFS) Trevor: light.1up.pdf light.6up.pdf light.pptx dark.1up.pdf dark.6up.pdf dark.pptx
Rafael: PDF
22.1, 22.2 * [Erickson] 5.1 - 5.4
L11 Oct 19 Graph Algorithms II (DFS) Trevor: light.1up.pdf light.6up.pdf light.pptx dark.1up.pdf dark.6up.pdf dark.pptx
Rafael: PDF
22.3 * [Erickson] 5.5, 6.1
Midterm Exam: Friday, Oct 20, 4:30pm to 6:00pm
Week 8 L12 Oct 24 Graph Algorithms III (directed graphs) Trevor: light.1up.pdf light.6up.pdf light.pptx dark.1up.pdf dark.6up.pdf dark.pptx
Rafael: PDF
22.4, 22.5 [DPV] 3.2
[Erickson] 6
L13 Oct 26 Graph Algorithms IV (minimum spanning trees) Trevor: light.1up.pdf light.6up.pdf light.pptx dark.1up.pdf dark.6up.pdf dark.pptx
Rafael: PDF
23 [DPV] 5.1
[Erickson] 7.1, 7.2, 7.5
Week 9 L14 Oct 31 Graph Algorithms V (single source shortest paths) Trevor: light.1up.pdf light.6up.pdf light.pptx dark.1up.pdf dark.6up.pdf dark.pptx
Rafael: PDF
24.1, 24.3 [Erickson] 8.6
L15 Nov 2 Graph Algorithms VI (all pairs shortest paths, formulating graph problems) Trevor: light.1up.pdf light.6up.pdf light.pptx dark.1up.pdf dark.6up.pdf dark.pptx
Rafael: PDF
23 [DPV] 5.1
[Erickson] 7.1, 7.2, 7.5
Week 10 L16 Nov 7 Graph Algorithms VII (max-flow and min-cut) Trevor: light.1up.pdf light.6up.pdf light.pptx dark.1up.pdf dark.6up.pdf dark.pptx
Rafael: PDF
Lap Chi's notes, 15
L17 Nov 9 Graph Algorithms VIII (max-flow and min-cut) Trevor: light.1up.pdf light.6up.pdf light.pptx dark.1up.pdf dark.6up.pdf dark.pptx
Rafael: PDF
Week 11 L18 Nov 14 Applications of Max-Flow and Min-Cut Trevor: light.1up.pdf light.6up.pdf light.pptx dark.1up.pdf dark.6up.pdf dark.pptx
Rafael: PDF
Lap Chi's notes, 16
L19 Nov 16 Complexity Intro & Reductions I Trevor: light.1up.pdf light.6up.pdf light.pptx dark.1up.pdf dark.6up.pdf dark.pptx
Rafael: PDF
34.1 [DPV] 8
[Erickson] 12 * for reductions: [Erickson] 1.1
Week 12 L20 Nov 21 Reductions II Trevor: light.1up.pdf light.6up.pdf light.pptx dark.1up.pdf dark.6up.pdf dark.pptx
Rafael: PDF
34.2
L21 Nov 23 Intractability I Trevor: light.1up.pdf light.6up.pdf light.pptx dark.1up.pdf dark.6up.pdf dark.pptx
Rafael: PDF
34.3
Week 13 L22 Nov 28 Intractability II Trevor: light.1up.pdf light.6up.pdf light.pptx dark.1up.pdf dark.6up.pdf dark.pptx
Rafael: PDF
34.4
L23 Nov 30 Intractability III Trevor: light.1up.pdf light.6up.pdf light.pptx dark.1up.pdf dark.6up.pdf dark.pptx
Rafael: PDF
34.5
Week 14 L24 Dec 5 Last lecture; topics to be determined Trevor: light.1up.pdf light.6up.pdf light.pptx dark.1up.pdf dark.6up.pdf dark.pptx
Rafael: PDF

Hand in a PDF file with your solutions via CrowdMark. We encourage you to prepare your solutions using LaTeX but you can use other software or submit handwritten assignments as long as they are legible. We have the right to take marks off for illegible answers.

When the CrowdMark instance is ready, all students enrolled in the class will receive an email with a link to their individual submission site. In order to submit, upload a separate PDF file (multiple pages are allowed) to each question. You may resubmit as often as necessary until the due date. (More detailed CrowdMark information is available at https://crowdmark.com/help/completing-and-submitting-an-assignment/.)

Marmoset will be used for the programming questions, and is available at https://marmoset.student.cs.uwaterloo.ca.

Assignments will appear in the following table, and will be due on the dates specified:

Assignment Number Date Posted Due (11:59pm EDT/EST) Hand In Via Markers Solutions
1 PDF Sep 12 Sep 25 CrowdMark
2 PDF Sept 28 Oct 6
Oct 16 8:00am
CrowdMark
3 PDF Oct 23 Nov 6 CrowdMark
4 PDF Nov 11 Nov 22 CrowdMark
5 PDF Nov 24 Dec 5 CrowdMark

Instructions for Assignments: Your written solutions will be judged not only for correctness but also for the quality of your presentation and explanations. In questions that involve designing an algorithm, (i) describe the main idea first, (ii) present clearly written pseudocode (e.g., at a level of details mimicking the style of the lectures, the model solutions, or the textbook), (iii) give a correctness proof/argument if it is not immediately obvious, and (iv) include an analysis (usually, of the running time). In all assignments, 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.

Collaboration Policy: The work you hand in must be your own. Unless specified otherwise, you can always use any result from the textbook, notes, or previous assignment just by citing it. You may discuss the assignment questions verbally with others, but you should come away from these discussions with no written or electronic records and you must acknowledge the discussion. Acknowledge any sources you have used. Any assistance received (from human or nonhuman sources) that is not given proper citation may be considered a violation of the university policies.

Programming Questions: Some assignments may have programming questions, where we ask you to code an algorithm. This is not a software engineering course; we will not test your code against inputs that do not match our specifications. However, your program should take care of the edge cases that are crucial to the algorithm's correctness or analysis. For example, unless the problem states so, you should not usually assume that the input size is a power of 2. We will post instructions about how to submit programming questions on Piazza.

Late Policy: Assignments (including programming questions) can be handed in up to 2 days late, but with a penalty of 25% per day.

• If you submit late but no more than 1 day late, you get a 25% penalty.
• If you submit more than 1 day late but no more than 2 days late, you get a 50% penalty.
• If you submit more than 2 days late, you get a grade of zero.

Short Term Absences and Other Extenuating Circumstances: If you use a 2-day short term absence that overlaps an assignment deadline, rather than granting an extension, we will waive the late penalties for the assignment. This gives you two extra days to submit without penalty. However, if you submit more than 2 days late, you will get zero.

In general, we cannot grant more than 2 extra days on assignments, as we might post solutions shortly after the late deadline. For longer absences, illnesses with a supporting Verification of Illness Form (VIF), or other extenuating circumstances, we may be able to offer another accommodation, like dropping the assignment and shifting the weight. Contact the Instructional Support Coordinator to discuss your options (see the table of course personnel below).

Reading Week Exception: Assignment 2 will be due Friday, October 6, directly before Reading Week. For this assignment, absences, VIFs, and other extenuating circumstances will be accommodated by pushing the deadline to after Reading Week: Monday, October 16, 8:00am. This extended deadline is a hard deadline and submissions after this deadline will get zero. If you do not have extenuating circumstances, the usual late policy applies (you can submit on Saturday, October 7 for a 25% penalty, or Sunday, October 8 for a 50% penalty).

Exam Study Day Exception: Assignment 5 will be due Monday, December 5 (the last day of classes). After the end of classes, there are two "study days" meant for recuperation and preparing for exams. For this assignment, absences, VIFs, and other extenuating circumstances will be accommodated by pushing the deadline to 2 days after the study days: Saturday, December 9, 11:59pm. This extended deadline is a hard deadline and submissions after this deadline will get zero. If you do not have extenuating circumstances, the usual late policy applies (you can submit on Wednesday, December 6 for a 25% penalty, or Thursday, December 7 for a 50% penalty).

• 5 assignments worth 8% each.
• An in-person midterm worth 20% (Friday, October 20, 4:30pm to 6:00pm).
• An in-person final exam worth 40% (date TBA).

We will use Piazza for all course announcements and as a forum for students to ask and answer questions. 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 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.

Piazza is not the place to dispute how assignments are marked. If you have a complaint, please follow the remark request process.

Instructor Email (at school name dot ca) Office Hours
Trevor Brown t35brown Thursday, 12-1pm, DC 2338
Rafael Oliveira r5olivei Tuesday, 4-5pm, DC 3144

Instructional apprentice Email (at school name dot ca)
Aseem Baranwalarbaranw
Abhibhav Garga65garg
Robert Wangr585wang
Teaching assistant Email (at school name dot ca)
Shaikh Shawon Arefin Shimonssarefin
Sabrina Mokhtaris4mokhta
Abhiroop Sanyala5sanyal
Cameron Sethcjmpseth
Shaokai Wangs853wang
Zhiying Yuzy3yu

IA and TA office hours will be announced on Piazza.

Instructional support coordinator

Instructional support coordinator Email (at school name dot ca)
Sylvie Davies sldavies

Points of contact for common questions

Note: If you decide to e-mail the course staff, you must use your uwaterloo Quest e-mail account (WatIAM/Quest userID @uwaterloo.ca); otherwise we cannot verify who you are and are limited on what we can accept and respond to.

Help Topic Contact
Assignment, Missed Deadline: We do not accept emailed assignments. The last files submitted before the deadline will be marked (submit early and often, even if not finished).
If the deadline is missed due to illness or other valid, verifiable reason, see Missed Work Due To Illness below.
Assignment Marking Error: Remark requests are due within one week of release of marks on CrowdMark/Marmoset. question by email. Details of how to make a request will be posted on Piazza.
Assignment Recording Error: Grades will be made available either through Learn or the course website. Details will be announced on Piazza. If you notice an error in the recorded value, please contact Sylvie Davies (CS 341 ISC).
Course Website Error: Contact Sylvie Davies (CS 341 ISC).
Enrollment: If Quest won't let you enroll or switch LEC or TUT sections without a permission/override number: Instructors and course staff are unable to help you. You must see a CS academic advisor.
General Course Help: IA/TA office hours or instructor office hours or Piazza.
Lecture Questions: IA/TA office hours or instructor office hours or Piazza.
Missed Work Due To Illness/Valid, Verifiable Reason (Assignments, Exams): Assignments, midterms, final exam: Validation required (see Verification of Illness Services at https://uwaterloo.ca/campus-wellness/health-services/student-medical-clinic but substitute Sylvie Davies (CS 341 ISC) for references to instructor). Make sure you also read the Math Faculty document on the consequences of submitting a VIF.
AccessAbility Services (AAS) exam accommodation forms (request to write at AAS): Submit to AAS at least 3 weeks before exam.

If you are person who likes a more detailed text book format, here are our recommendations for sources available online.

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

This book is available electronically through the UW library catalog.

• [KT] Kleinberg and Tardos, Algorithm Design (QA76.9.A43K54 2006)
• [BB] Brassard and Bratley, Fundamentals of Algorithmics (QA9.58.B73 1996)
• [GJ] Garey and Johnson, Computers and Intractability: A Guide to the Theory of NP-Completeness (QA76.6.G35 1979)

The following resource is also useful for the course but more importantly for technical interviews you may have:

• Adnan Aziz and Amit Prakash, Algorithms for Interviews, 2010. Available here. Nice small collection of problems and solutions

Plagiarism

Plagiarism is a very serious academic offence and is penalized accordingly. When you plagiarize you damage the learning experience for yourself and others. 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.

Mental Health Resources

Mental Health: If you or anyone you know experiences any academic stress, difficult life events, or feelings like anxiety or depression, we strongly encourage you to seek support.

On-campus Resources

Off-campus Resources

• Good2Talk (24/7): Free confidential help line for post-secondary students. Phone: 1-866-925-5454
• Here 24/7: Mental Health and Crisis Service Team. Phone: 1-844-437-3247
• OK2BME: set of support services for lesbian, gay, bisexual, transgender or questioning teens in Waterloo. Phone: 519-884-0000 extension 213

Diversity: It is our intent that students from all diverse backgrounds and perspectives be well served by this course, and that students' learning needs be addressed both in and out of class. We recognize the immense value of the diversity in identities, perspectives, and contributions that students bring, and the benefit it has on our educational environment. Your suggestions are encouraged and appreciated. Please let us know ways to improve the effectiveness of the course for you personally or for other students or student groups. In particular:

• We will gladly honour your request to address you by an alternate/preferred name or gender pronoun. Please advise us of this preference early in the semester so we may make appropriate changes to our records.
• We will honour your religious holidays and celebrations. Please inform of us these at the start of the course.
• We will follow AccessAbility Services guidelines and protocols on how to best support students with different learning needs.

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. [Check the Office of Academic Integrity for more information.]

Grievance: A student who believes that a decision affecting some aspect of their university life has been unfair or unreasonable may have grounds for initiating a grievance. Read Policy 70, Student Petitions and Grievances, Section 4. When in doubt, please be certain to contact the department’s administrative assistant who will provide further assistance.

Discipline: A student is expected to know what constitutes academic integrity to avoid committing an academic offence, and to take responsibility for their actions. [Check the Office of Academic Integrity for more information.] A student who is unsure whether an action constitutes an offence, or who needs help in learning how to avoid offences (e.g., plagiarism, cheating) or about “rules” for group work/collaboration should seek guidance from the course instructor, academic advisor, or the undergraduate associate dean. For information on categories of offences and types of penalties, students should refer to Policy 71, Student Discipline. For typical penalties, check Guidelines for the Assessment of Penalties.

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.

MOSS (Measure of Software Similarities) is used in this course as a means of comparing students' assignments to ensure academic integrity. We will report suspicious activity, and penalties for plagiarism/cheating are severe. Please read the available information about academic integrity very carefully.

Discipline cases involving any automated marking system such as Marmoset include, but are not limited to, printing or returning values in order to match expected test results rather than making an actual reasonable attempt to solve the problem as required in the assignment question specification.

Appeals: A decision made or penalty imposed under Policy 70, Student Petitions and Grievances (other than a petition) or Policy 71, Student Discipline may be appealed if there is a ground. A student who believes they have a ground for an appeal should refer to Policy 72, Student Appeals.

Note for students with disabilities: AccessAbility Services, located in Needles Hall, Room 1401, collaborates with all academic departments to arrange appropriate accommodations for students with disabilities without compromising the academic integrity of the curriculum. If you require academic accommodations to lessen the impact of your disability, please register with AccessAbility Services at the beginning of each academic term.