Introduction to algorithm design and analysis. Graph algorithms, greedy algorithms, data structures, dynamic programming, maximum flows.


Instructor: Prof. Jérôme Waldispühl (

Teaching Assistants:

Lectures: Tuesday & Thursday 11:35am to 12:55pm in Maass Chemistry Building 112.

Office hours:

Prof. Jérôme WaldispühlTue/Thu 13:00-14:00pmENGTR 3106
Hossein AboutalebiWed 11:30-1:30MC303
Alexander ButyaevMon 10-12ENGTR 3110
Carlos Gonzalez OliverWed 14-16ENGTR 3110
Roman Sarrazin-GendronFri 11-1ENGTR 3110
Antoine SouléIn charge of forumOnline!

Course Webpage:

Course Material:
All the material needed for this class will be available on the public course web page. There is no required textbook. However, we recommend the following textbooks from which most lectures will be based upon:

Lecture slides will be made available in PDF form on the course web page. Lectures will be recorded and available on MyCourse. Instructions to borrow a E-book online are available at

Discussion Board:
The official discussion board for this class is available at You can automatically login into this forum using your SOCS login and password. If you do not have a SOCS account, you can create one at from any computer in the mcgill network. Please, note that you can access it only from the McGill network. If you are out of the campus, you will need to use the McGill VPN (

Your final grade will be calculated as follows:

The exams are closed book. However, you will be allowed 4 pages of notes at the final exam. No electronic devices are allowed (this includes noise-cancelling headphones).


Release DateDue DateAnnounce
Apr 18thJérôme Waldispühl will hold hold office hours from 11am to 1pm.
Apr 15thA final practice exam is now available. For your convenience, we provide two versions. One without answers (practice_final_COMP251_no_answers_W2017.pdf) and another one with solutions (practice_final_COMP251_with_answers_W2017.pdf).
Apr 6thApril 9th at 11:59pmFill the online form to suggest concepts and problems you would like to review during the review lecture.
Mar 28thApril 11th at 11:59pmThe fifth assignment is now available. We will accept late submissions of assignment 5 (only) until April 18th, without penalty. Later submissions will be refused.
Mar 28thApril 8th at 11:59pmThe fourth assignment is now available. We provide a template file for the programming question and a sample output output_HW4Q1.txt.
Mar 16thMarch 26thAssignment 3 due date has been postponed to March 26th, 11h59pm.
Mar 16thThe office hours of R. Sarrazin-Gendron are moved from 1pm to 3pm.
Mar 14thThe office hours of J. Waldispühl are moved from 3pm to 4pm.
Mar 8thC. Gonzalez and R. Sarrazin-Gendron will hold their office hours this Wednesday from 2pm to 4pm in TR3110.
Mar 7thThe office hours of J. Waldispühl are extended to 3pm.
Mar 3rdA mid-term practice exam is now available. For your convenience, we provide two versions. One without answers (practice_midterm_COMP251_W2017_no_answers.pdf) and another one with solutions (practice_midterm_COMP251_W2017_with_answers.pdf).
Note: You will be allowed to bring one crib sheet (i.e. 2 pages) in letter or A4 format at the mid-term exam.
Mar 3rdThe final examination is scheduled on April 21st at 14h00.
Mar 1stMar 22th at 11:59pmThe third assignment is now available. You will use the template files,, and (Note: this file has been updated after Assignment 2). We also provide you the test files: bf1.txt, bf2.txt, bf3.txt, bf4.txt, ff2.txt, and ff226000000.txt to help you to check your programs.
Mar 1stMar 5Fill the survey to allow us to customize the review session on March 7.
Feb 12thFeb 26th at 11:59pmThe second assignment is now available. You will use the template files,, and We also provide you the test files unionfind.txt, mst1.txt, and g1.txt to help you to check your programs.
Jan 26thThe first assignment and Java template file have been updated. Changes will not affect your previous answers, and you are welcome to use the previous template if you prefer. A description of the changes are indicated in this README file.
Jan 23rdOffice hours have been updated. Please, have a look at the updated schedule.
Jan 15thFeb 1st at 11:59pmThe first assignment is now available. You will use the template file and the jar file JavaPlotBuilder.jar.
The files have been updated on Jan 21. Please, check that you use the last versions of the assignment and Java files. A description of the list of changes is available [HERE].
Jan 5thJan 8th at 11:59pmAnswer an anonymous quiz that will be used to calibrate the review session and the whole class during the semester.


Lecture 0Jan 5thIntroduction[SLIDES]
Answer an anonymous quiz
Lecture 1Jan 10thCOMP250 review[SLIDES]
Lecture 2Jan 12thHashing[SLIDES] & Online quizChapter 11 of [CLRS2009]
Lecture 3Jan 17thHeaps & Heapsort[SLIDES] & Online quizChapter 6 of [CLRS2009]
Lecture 4Jan 19thBST and AVL trees[SLIDES] & Online quiz
Lecture 5Jan 24thRed-black trees[SLIDES] & Online quizChapter 13 of [CLRS2009]
Lecture 6Jan 26thDisjoint sets[SLIDES] & Online quizChapter 21 of [CLRS2009]
Lecture 7Jan 31thGreedy algorithms (Scheduling, Huffman coding)[SLIDES] & Online quizChapter 16 of [CLRS2009]
Lecture 8Feb 2ndElementary graph algorithms[SLIDES] & Online quizChapter 22 of [CLRS2009]
Lecture 9Feb 7ndTopological sort and strongly connected components[SLIDES] & Online quizChapter 22 of [CLRS2009]
Lecture 10Feb 9thMinimum Spanning Tree[SLIDES] & Online quizChapter 23 of [CLRS2009]
Lecture 11Feb14thSingle source shortest path[SLIDES] & Online quizChapter 24 of [CLRS2009]
Lecture 12Feb 16thBipartite graphs[SLIDES] & Online quizChapter 1.1 of [KT2006]
Lecture 13Feb 21stNetwork flow 1[SLIDES] & Online QuizChapter 26 of [CLRS2009]
Lecture 14Feb 23rdNetwork flow 2[SLIDES] & Online QuizChapter 26 of [CLRS2009]
Midterm reviewMar 7thReview session[SLIDES] & Survey
Mid-termMar 9thCover all the material from Lecture 1 to 14.
Note: Examination at regular class hours (11:35-12:55) in ADAMS Auditorium
Lecture 15March 14thDynamic Programming 1 (weighted interval scheduling, Bellman-Ford)[SLIDES]Chapter 6 of [KT2006]
Lecture 16Mar 16thDynamic Programming 2 (sequence alignment)[SLIDES]Chapter 6 of [KT2006]
Lecture 17Mar 21stDynamic Programming 3 (Bellman Ford, knapsack problem)[SLIDES] & Online QuizChapter 6 of [KT2006]
Lecture 18Mar 23rdDivide-and-conquer 1 (Merge sort & integer multiplication)[SLIDES] & Online QuizChapter 5 of [KT2006]
Lecture 19Mar 28Divide-and-conquer 2 (Master Theorem)[SLIDES] & Online QuizChapter 4 of [CLRS2009]
Lecture 20Mar 30thAmortized analysis[SLIDES] & Online QuizChapter 17 of [CLRS2009]
Lecture 21Apr 4thRandomized algorithms (Global min-cut, randomized quick sort)[SLIDES] & Online quizChapter 13 of [KT2006]
Lecture 22Apr 6thProbabilistic analysis[SLIDES]Chapter 5 of [CLRS2009]
Lecture 24Apr 11thReview[SLIDES]
Note: This schedule is subject to modification.


The official prerequisite for this course is COMP 250 Introduction to Computer Science. We recommend the students to review the material covered in this class. The students must also be familiar with basic concepts in discrete mathematics and probability. Therefore, courses such as MATH 240, 363, or 235 are recommended (but not required).

Policy on discussion Board
We will use a new forum system available at: (i.e. we will not use the forum in MyCourse).
You will be automatically registered in this forum and will have the possibility to vote for the most useful questions and answers. Students with the most voted questions and answers (after validation by a moderator) will receive bonus points.
Please follow common sense rules and etiquette for discussion board postings: be polite, avoid texting shorthand ("ur" instead of "you are", ...), choose a suitable subject line for your posting and use multiple postings for multiple subjects, keep your postings brief, etc.

Policy on collaborations
We greatly encourage you to discuss the assignment problems with each other. However, these discussions should not so far that you are sharing code or giving away the answer. A rule of thumb is that your discussions should considered public in the sense that anything you share with a friend should be sharable with any student in the class. We ask you to indicate on your assignments the names of the persons with who you collaborated or discussed your assignments (including the TA’s and the instructor).

Policy on re-grading
If you wish us to re-grade a question on an exam (or assignment), we will do so. However, to avoid grade ratcheting, we reserve us the right to re-grade other questions on your exam as well.

Policy on final grades
I will use the same formula for calculating your final grade for everyone. I understand that your performances may be influenced by many factors, possibly out of your control. However, that is the only way we can be fair. The only exceptions will be medical exceptions. In that case, I will require a medical note, which has to be also reported to McGill, and to be informed as early as possible. Failure to comply to these rules, may results in the impossibility to invoke a medical exception.

Policy on Assignments
Due date/time, location/mode for returning your solutions, and accepted formats will be announced in class and indicated on the course web page.
Failure to return your assignment in time will results in penalties and possibly absence of grading. The first time that you return late your assignment, you will receive a penalty of 20% on your normal grade if and only if your assignment is returned less than 24h after the end of the deadline. In all other cases, your assignment will not be graded.
Assignments may include guiedlines and require particular formatting procedures. Solutions that do not follow the required format will not be graded.
The quality of the presentation of your solution is important. Unreadable material, cryptic notations, or bad organization of the material may result in absence of grading. Clarity of your explanations will be an integral part of your final grade.

Policy on programming code
Questions in assignments may require you to write a Java program. We will provide, as much as possible, input and output data to test your programs. However, it will be your duty to ensure that your Java files compile on LINUX SOCS workstations. We will not grade programs that do not compile on these machines.

Use of French in assignments and exams
In accordance with McGill University’s Charter of Students’ Rights, students in this course have the right to submit in English or in French any written work that is to be graded.

McGill policies
McGill University values academic integrity. Therefore, all students must understand the meaning and consequences of cheating, plagiarism and other academic offenses under the Code of Student Conduct and Disciplinary Procedures. See this link for more information.


For any issue that is not directly related to the material covered in the class, you can contact me directly at:

3630 University Street, Room 3106, Montreal QC H3A 0C6
(Phone) +1 514 398 5018

Based on a template from