CMPT 307
Data Structures & Algorithms - Summer 2019
Announcements
- Aug 2: I'll have 2-hour office hours on Wed, Aug 7, 11:30-13:30.
- Aug 2: The final exam on Aug 9 will be on all topics of the course, with equal emphasis. You'll have 3 hours for an exam that will be roughly two quizzes in size. To prepare, go over all lecture slides and notes, HWs, quizzes, and the textbook. The questions on the final exam will be similar to those on the quizzes we had.
Note that there won't be any questions on the final asking you to prove some problem NP-complete. However, you do need to know what an NP-problem is (using the concept of a "guess-and-check" algorithm, for example), and you need to be able to state a couple of examples of NP-complete problems you saw in class.
I won't be asking you about the randomized algorithm for Min-Cut which we haven't covered in class. I may ask some basic questions on randomized algorithms (and basic probability theory that we saw in class).
- July 30: Quiz 4 solutions are now posted.
older announcements...
- July 25: Quiz 4 will cover Lectures 22-27 (inclusive): Max Network Flows (Min Cut), with applications. (NP-completeness will not be part of Quiz 4, but rather appear on the final exam.)
- July 21: The solutions to HW 4 are now posted.
- July 14: Quiz 3 solutions are now posted.
- July 4: No classes on Wed, July 10, and Fri, July 12, as I'm away at a conference.
- July 1: Quiz 3 will cover Dynamic Programming, lectures 16-21 (inclusive).
- June 28: Starting July 3, our classes will move to SWH 10081 (due to construction noise near our present class room).
- June 20: There will be no class on Wed, June 26 (as I'll be away).
- June 16: Quiz 2 will cover the material from lectures 9-15 (inclusive), that is, Greedy Algorithms and Divide&Conquer Algorithms (recurrences).
- June 16: The solutions to HW 2 are now posted.
- May 24: Quiz 1 will cover the material from lectures 1-8 (inclusive), that is, stable matchings and graph algorithms (BFS, DFS, bipartiteness, topological ordering of DAGs), Dijkstra's algorithm, and priority queue (min-heap) data structures. The questions on the quiz will be similar to those on HW 1. You may be asked to describe an algorithm, do a proof of correctness, analyze the runtime, and run the algorithm on a small input example. To prepare, study the lecture notes and the textbook, and make sure you have worked on the HW problems by yourself to understand the solutions well enough to be able to solve similar questions on the quiz. The more problems you work on before the quiz, the easier it will be for you during the quiz.
- May 23: Each Monday, 12:30-1:20 pm, will be additional office hours by TAs. The room is ASB 9808.
- May 16: HW 1 is now available.
Course description
The course introduces concepts and problem-solving techniques useful for the design and analysis of efficient algorithms.
- Topics
- Texts
- Lectures
- Office hours
- Marking scheme
- Motivating example: the stable matching problem
- Greedy (graph) algorithms, BFS, DFS, Dijkstra's, Kruskal's, and Prim's
- Simple data structures: priority queues (with heaps) and union-find
- Divide & Conquer algorithms (solving recurrences)
- Dynamic Programming algorithms
- Network Flow algorithms and matching
- Randomized algorithms
- NP-completeness
- Advanced topics
- Algorithm Design by J. Kleinberg and E. Tardos, 2006 [main]
- Introduction to Algorithms by T.H. Cormen, C.E. Leiserson, R.L. Rivest, and C. Stein, 2001 [optional]
day | time | room |
---|---|---|
Mon | 15:30-16:20 | SWH 10081 |
Wed | 15:30-16:20 | SWH 10081 |
Fri | 15:30-16:20 | SWH 10081 |
day | time | room |
---|---|---|
Mon | 12:30-13:20 | ASB 9808 (by TAs) |
Wed | 12:30-13:20 | TASC1 8011 |
Fri | 12:30-13:20 | TASC1 8011 |
- four 50-min in-class quizzes @ 15% each,
- final exam @ 40%.
Teaching staff
Instructor: Valentine Kabanets (kabanets@cs.sfu.ca), Office: TASC1 8011
TAs: Ermin Hodzic (ehodzic@sfu.ca), Amirhossein Kazeminia (akazemin@sfu.ca), Shohre Masoumi (smasoumi@sfu.ca)
If you have grading-related questions, please email the TAs and ask for an appointment. If you still have questions after meeting with the TA, then come and see me.
Important dates
The 50-minute quizzes will be given during our regular lecture times on the following dates.
Quiz 1 | Quiz 2 | Quiz 3 | Quiz 4 |
---|---|---|---|
June 3 | June 24 | July 8 | July 29 |
A--L in AQ 3181; M--T in AQ 3150; W--Z in AQ 3154 | IMAGTH | IMAGTH | IMAGTH |
Note: Quizzes 2, 3, and 4 will be held in Images Theatre (IMAGTH) (for everyone). Quiz 1 will have three sections: The students with the last name starting with a letter between A to L (inclusive) will write the quiz in AQ 3181; the students whose last name begins with a letter between M to T (inclusive) will write the quiz in AQ 3150; the students whose last name begins with a letter between W and Z (inclusive) will write the quiz in AQ 3154.
Final exam: Aug 9, 15:30-18:30, SSCC 9001
Assignments
I'll post homework assignments & solutions.
- Homework 1 solutions
- quiz 1 solutions
- Homework 2 solutions
- quiz 2 solutions
- Homework 3 solutions
- quiz 3 solutions
- Homework 4 solutions
- quiz 4 solutions
Lecture notes & Slides
I'll post my lecture notes (slides), and the reading assignment.
- 05/6: Lecture 1: Intro; Stable matching algorithm: correctness analysis. Read: KT, Sec. 1.1 (for the algorithm);
Secs. 2.1 and 2.2 (for some background). Also check out this
Nobel Prize note about the stable matching algorithm!
Slides for lectures 1-2 (Stable Matching Problem) in PDF and in OneNote
- 05/10-13: Lectures 2-3: Stable matching algorithm (cont'd): man-optimal matching; woman-pessimal matching; efficient implementation (using arrays & linked lists). Read: KT, Secs. 2.3 & 2.4. (If you want to read ahead: KT, Secs. 2.5 & 3.1-3.3).
- 05/15: Lecture 4: Graphs (basic definitions & representations of
graphs); BFS; runtime
O(m+n); graph
reachability Reach(s,t); connected components algorithms. Read: KT, Secs. 3.1-3.4. (Read ahead: KT, Secs. 3.5-3.6.)
Slides for lectures 4-6 (Graph algorithms) in PDF and in OneNote
- 05/17: Lecture 5: 2-Colorability algorithm; Digraphs (BFS and DFS still work). Read: KT, Secs. 3.5-3.6. (Read ahead: KT, Secs. 4.4-4.6.)
- 05/22: Lecture 6: topological ordering for DAGs; Queues and stacks (to implement BFS and DFS, resp.) Read: KT, Secs. 3.4-3.6, 4.4. (Read
ahead: KT, Secs. 4.4-4.6.)
Slides for lectures 7-11 (Greedy graph algorithms) in PDF and in OneNote
- 05/24: Lecture 7: Dijkstra's algorithm. Read: KT, Secs. 4.4, 2.5. Read ahead: KT, Secs. 4.5, 4.6.)
- 05/27: Lecture 8: Dijkstra's algorithm: implementation using priority queues; Min-Heaps. Read: KT, Secs. 4.4, 2.5. Read ahead: KT, Secs. 4.5, 4.6.)
- 05/29: Lecture 9: Min Spanning Tree (MST): Kruskal's algorithm; correctness analysis (via "promising"). Read: KT, Secs. 4.5. (Read ahead: KT, Secs. 4.6.)
- 05/31: Lecture 10: MST: Prim's algorithm; its correctness analysis; implementation of Prim's algorithm using priority queues. Read: KT, Secs. 4.5, 4.6. (Read ahead: KT, Sec. 4.1.) Here are some lecture notes on greedy algorithms
- 06/5: Lecture 11: Implementation of Kruskal's algorithm; Union-Find data structure.
- 06/7: Lecture 12: Job (interval) scheduling. Read: KT, Sec. 4.1, 4.2. (Read ahead: Sec. 5.1.)
Slides for Lectures 12-13 (the Interval scheduling problems) (pdf) and (One Note)
- 06/10: Lecture 13: Interval partitioning (lecture scheduling) Read: KT, Sec. 4.1, 4.2. (Read ahead: Sec. 5.1.)
- 06/12: Lecture 14: Job scheduling to minimize lateness. Divide & Conquer algorithms: Merge Sort; Recurrences. Read: KT, Secs. 4.2, 5.1. (Read ahead: KT, Secs. 5.3, 5.5, 6.1, 6.2.)
- 06/14: Lecture 15: Divide & Conquer algorithms: Counting Inversions; Multiplying two n-bit numbers.
- 06/17: Lecture 16: Dynamic programming: The wall climbing problem. Read: KT, Secs. 6.1, 6.2. (Read ahead: KT, Secs. 6.1, 6.4).
- 06/19: Lecture 17: DP: Weighted Interval Scheduling, Knapsack problem. Read: KT, Secs. 6.1, 6.4. (Read ahead: KT, Sec. 6.8).
- 06/21: Lecture 18: DP: Knapsack problem.
- 06/28: Lecture 19: DP: All-Pairs Shortest Paths (Floyd-Warshall algorithm). Read: KT, Secs. 6.8 (and the lecture notes on DP for Floyd-Warshall - see under Lecture 16). (Read ahead: KT, Secs. 6.10, 7.1)
- 07/3: Lecture 20: DP: Bellman-Ford algorithm, and Negative Cycle detection algorithm. Read: KT, Secs. 6.10 (and the lecture notes on DP - see under Lecture 16). (Read ahead: KT, Sec. 7.1)
- 07/5: Lecture 21: DP: Longest Common Subsequence. (see the notes on DP - under Lecture 16). (Read ahead: KT, Secs. 7.1-7.2.)
- 07/15: Lecture 22: Max Network Flow. Read: KT, Sec. 7.1. (Read ahead: KT, Sec. 7.2.)
- 07/17: Lecture 23: Max Network Flow: Ford-Fulkerson algorithm. Read: KT, Secs. 7.1-7.2.
- 07/19: Lecture 24: Max Network Flow: Correctness analysis of the Ford-Fulkerson algorithm, and Max-Flow=Min-Cut. Read: KT, Secs. 7.2-7.3. (Read ahead: KT, Secs. 7.5-7.6, 7.11.)
- 07/22: Lecture 25: Max Network Flows: Applications (Max Bipartite Matching and Hall's theorem). Read: KT, Secs. 7.5, 7.6, and 7.11.
- 07/24: Lecture 26: Max Network Flow: Project Selection; Run Time analysis: Scaling algorithm, and Shortest-Path algorithm for choosing an augmenting path. Read: KT, Sec. 7.5. (Read ahead: KT, Sec. 13.2.)
- 07/26: Lecture 27: Max Network Flow: Menger's Theorem. Randomized Algorithms: Contention resolution. Read: KT, Secs. 13.2.
- 07/31: Lecture 28: Classes P and NP; NP-completeness.
- 08/2: Lecture 29: Coping with NP-complete problems, and Course Review. Read: KT, Chap. 10.
Slides for lectures 14-15 (PDF) and (OneNote)
Slides for Lectures 16-18 (PDF) and (OneNote) Here are also some additional lecture notes for some of the DP problems discussed in class.
Slides for Lectures 19-21 (PDF) and (OneNote)
Slides for Lectures 25-27 (PDF) and (OneNote)