CS 514, Algorithms, Spring 2024

Coordinates W/F, 8:30-9:50am, KEC 1003 [Registrar] [Canvas] [Ed Discussion]
Instructor Liang Huang (huanlian@)
TA Ning Dai (dain@)
Office Hours Instructor: W/F 11:30-11:55am (KEC 2069)
TA: M/T 4-5pm (KEC 3087).
Extra office hours available before exams.
Textbooks [H] My Course Notes (default reference).
[CLRS] Introduction to Algorithms, 2nd/3rd/4th edi. (2nd reference).
[KT] Kleinberg and Tardos, Algorithm Design (DP chapter online, all slides online)
[R] Roughgarden, Algorithms Illuminated (videos and slides online)
[DPV] Dasgupta, Papadimitriou, and Vazirani (DPV). Algorithms (full text online via berkeley)
[E] Jeff Erickson. Algorithms, Etc. (full text online)
How to Think Like a Computer Scientist: Learning Python (full text online)
Grading (tentative) Midterm (week 7): 25%, Final: 25%, Quizzes (weeks 2 & 5): 6+10=16%.
Weekly homework (1-6, 8-10): 3x8%+4%+2%=28%+2%.
background survey: 2%. picking up graded papers: 2%; post-midterm survey: 2%.
Total extra credit: 2% (more extra credit will be given in quizzes/exams).
For HW1-9, any complete submission automatically gets 2%.
The other 1% is based on blackbox testing of the specified coding problem.
Coding must be done in Python 3.
HW is due every Tuesday 9:59pm. No late submission is accepted.

Grading Curve: (>90 OR top 25%): A/A-; (<70 AND bottom 25%): C+ or lower; others: B+/B/B-. (i.e., at least 1/4 will get A/A- and at most 1/4 will get C+ or lower).

Prerequisites Students are assumed to be familiar with Data Structures (CS 261) and fluent in at least one mainstream language (C/C++, Java, Python). We'll start with a brief review of Data Structures integrated with a Python tutorial.
Other Policies Canvas is for announcements (you'll receive an email for each announcement I made on Canvas) and checking grades, and Ed Discussion is for discussions.

For technical questions, please come to office hours. Or you can post a question on Ed Discussion, but please check if the same question has been asked by other students before posting.
For questions about grading, please come to TA office hours.
Do not email us unless you have a personal issue, in which case please always cc the TA.


The purpose of this course is six-fold:

Topics Covered

  1. Python Tutorial, Review of Basic Data Structures, Sorting and Selection
    (divide-n-conquer, quicksort/quickselect, mergesort, BSTs, memoization, heaps and heapsort, priority queue, hashing, hashed heap, etc.)
  2. Basic Complexity Analysis (Master equation, recursion tree method, amortization, etc.)
  3. Dynamic Programming (DP)
  4. Graph Algorithms: BFS/DFS, topological sort, Dijkstra, Viterbi, Prim, Kruskal, TSP
  5. NP-Completeness

Detailed Schedule and Materials

1 (Wed) Admin
Python Tutorial (first 5 pages)
quicksort: in-place vs. out-of-place
quicksort analyses: best-case \(O(n \log n)\); worst-case \(O(n^2)\)
array concatenation is \(O(n)\)
in \(n!\) permutations, \(2^{n-1}\) are worst-case
quicksort <-> BST (buggy qsort)

(Fri) quickselect
mergesort; two-pointers

(qselect, qsort->bst)
2 (Wed) discussions of HW1
number of inversions using mergesort;
recursion with byproduct

(Fri) longest path in binary tree [video 1] [video 2]

(msort, inversions, longest)
Fri: Quiz 1
(covers HW1)
3 priority queue, lowerbound, datastream
slides for nbest
(priority queue)
4 dynamic programming (DP): basics [slides] HW4
(DP: part 1)
5 dynamic programming (DP): LIS/LCS HW5
(DP: part 2)
Wed: Quiz 2
(covers HWs 1-3)
6 dynamic programming (DP): advanced HW6
(DP: part 3)
7 midterm review problems [solutions] no HW7 Fri: Midterm
8-9 graph algorithms and their connections to DP;
Topological sort
Viterbi algorithm
Dijkstra algorithm
10 challenge problem and final review
full DP slides (pages 11-17)
Final Review Questions and Solutions
(RNA: connecting all topics)
11 FINAL Mon 6/10 6pm
same room, closed book, closed notes


The last two are different from the rest in the sense that they ask you to submit your output to given testcases rather than programs (so that you can code in any language, and their online judge system is as easy as a diff). There are many other online judge systems that do not support Python (traditionally ACM/ICPC uses C/C++/Java/Pascal), such as the classical uva (Universidad de Valladolid), poj (Peking University), tju, hit, hust, bjtu, etc. (almost all major Chinese universities run their own online judge systems); you can hone your C/C++/Java skills there if you have extra time. Thanks to my former intern Zhuoran Yu for compiling this list.

To prepare for coding interviews, you have to practice on some of the above (say, solving at least 20 problems on codeforces, with at least two from each topic). To prepare for ACM/ICPC, you have to practice a lot (solving at least 100 problems on zoj/poj).

Liang Huang