CS 161: Design and Analysis of Algorithms (Spring 2017)

[ Course Schedule | Midterm and Final | Homework Assignments | Recitations | Resources ]

Instructor: Mary Wootters (email: marykw at cs)

Location and time: Monday and Wednesday 3:00 PM - 4:20 PM, Hewlett 200

Important! Sign up on Piazza for discussions and announcements.
We strongly encourage discussion and asking questions on Piazza. Questions to the course staff (that are not addressed to a specific person) can be sent using a private post in Piazza.

Course Description
This course will cover the basic approaches and mindsets for analyzing and designing algorithms and data structures. Topics include the following: Worst and average case analysis. Recurrences and asymptotics. Efficient algorithms for sorting, searching, and selection. Data structures: binary search trees, heaps, hash tables. Algorithm design techniques: divide-and-conquer, dynamic programming, greedy algorithms, amortized analysis, randomization. Algorithms for fundamental graph problems: minimum-cost spanning tree, connected components, topological sort, and shortest paths. Possible additional topics: network flow, string searching.

Prerequisites: CS 103 or CS 103B; CS 109 or STATS 116.

Requirements: 7 homework assignments (35%), a midterm (25%), and a final exam (40%).
There will be no late days. However, we will drop your lowest homework grade.
Note: In order to compute scores on the homework (in deciding which to drop and for averaging), we will normalize the scores by the number of points possible. That is, if 40 points were possible on the homework and you scored a 35, this would count as 35/40 = 0.875.

Teaching Assistants
David Eng, dkeng at stanford
Luna Frank-Fischer [Head TA], luna16 at stanford
Neha Gupta nehgupta at stanford
Jessica Su jtysu at stanford
Daniel Wright dlwright at stanford
Andi Yang, andiy at stanford
Wilbur Yang, wilbury at stanford

Sign up for office hours on QueueStatus.

Course Schedule and Lecture Notes

Topics and readings for future lectures are tentative and may be changed as the course proceeds. The readings refer to the 3rd edition of CLRS (see Resources below), but older editions should be fine as well.

Monday Wednesday Friday
4/3
Introduction, Why are you here?
Read: Ch. 1
Notes (draft)
Slides (ppt)
4/5
MergeSort, Recurrences, Asymptotics
Read: Ch. 2.3, 3
Notes (draft)
Slides (ppt) (draft)
Slides (pdf) (draft)
Slides (pdf, low quality) (draft)
4/7
Homework 1 released
4/10
Asymptotics (for real this time). Solving recurrences and the master theorem.
Read: Ch. 4.3-4.5
Dasgupta-Papadimitriou-Vazirani Sec. 2.2: [pdf]
Notes (draft)
Slides (pdf) (draft)
Slides (pdf, low quality) (draft)
4/12
Median and Selection
Read: Ch. 9
Notes (draft)
Slides (ppt)
Slides (pdf)
Slides (pdf, low quality) (draft)
(Note: Slides have been updated since lecture. Now with fewer typos!)
4/14
Homework 1 due
Homework 2 released
4/17
Quicksort, Probability and Randomized Algorithms
Read: Ch. 7, 5
Notes (draft)
Slides (ppt)
Slides (pdf)
Slides (pdf, low quality) (draft)
4/19
Sorting Lower Bounds, Counting Sort
Read: Ch. 8.1-2
Avrim Blum's Notes on sorting lower bounds
Notes on Bucket Sort and Radix Sort (draft)
Slides (ppt)
Slides (pdf)
Slides (pdf, low quality) (draft)
4/21
Homework 2 due
Homework 3 released
4/24
Binary Search Trees
Read: Ch. 12
Notes (draft)
Slides (ppt)
Slides (pdf)
Slides (pdf, low quality) (draft)
4/26
Hashing
Read: Ch. 11
Notes (draft)
Slides (ppt)
Slides (pdf)
Slides (pdf, low quality) (draft)
4/28
Homework 3 due
Homework 4 released
5/1
Graphs, DFS, BFS
Read: Ch. 22
Additional Reading that might be helpful: Kleinberg and Tardos, Chapter 3
Notes (draft)
Slides (ppt)
Slides (pdf)
Slides (pdf, low quality) (draft)
5/3
Strongly Connected Components
Read: Ch. 22.5 (NOTE: this reading assignment was garbled before, it is fixed now!)
Notes (draft)
Slides (pdf)
Slides (pdf, low quality) (draft)
5/8
Homework 4 due (NOTE the extension to Monday)
5/8
Dijkstra's Algorithm
Read: Ch. 24.1, 24.3
Notes (draft)
Slides (ppt)
Slides (pdf)
Slides (pdf, low quality) (draft)
5/10
MIDTERM
In class
(Hewlett 200, 3:00-4:20)
5/12
Homework 5 released
5/15
Dynamic Programming and shortest paths: Bellman-Ford, Floyd-Warshall
Read: Ch. 25.2, 15.1
Notes: details of Bellman-Ford Algorithm (Lecture 11.5)
Notes: Lecture 12 (draft)
Slides (pdf)
Slides (pdf, low quality) (draft)
5/17
Examples of dynamic programming: Longest common subsequence, Knapsack, Independent Set
Read: Ch. 15.4
Notes (draft)
Slides (ppt)
Slides (pdf, low quality) (draft)
5/19
Homework 5 due
Homework 6 released
5/22
Greedy Algorithms
Read: Ch. 16.1,16.2,16.3
Notes (draft)
Slides (pdf)
Slides (pdf, low quality) (draft)
5/24
Minimum Spanning Trees (MST)
Read: Ch. 23
Notes (draft)
Slides (pdf)
Slides (pdf, low quality) (draft)
5/26
Homework 6 due
Homework 7 released
5/29
Memorial Day (no class)
5/31
Minimum Cut and Karger's algorithm
Notes (draft)
6/2
Homework 7 due
6/5
Maximum Flow and Ford-Fulkerson
Notes (draft). Read: Ch. 26.1-3
6/7
What's Next?
6/9
FINAL EXAM

Midterm and Final

Midterm: Wednesday, May 10, in class (Hewlett 200, 3:00 pm - 4:20 pm) - [problems] [solutions]
Final: Friday, June 9, Hewlett 200, 3:30 pm - 6:30pm

Both the midterm and final are closed-book. In the midterm, you are allowed to bring one letter-sized double-sided page of notes, that you have prepared yourself. In the final, you are allowed to bring two letter-sized double-sided page of notes that you have prepared yourself.

The following practice exams are posted here as a resource; the material covered is similar to what we covered this quarter, but not identical.

Practice Midterm 1
Solutions to the Practice Midterm 1
Practice Midterm 2
Solutions to the Practice Midterm 2

Finals from Previous Years

The following final exams are taken from previous offerings of the class. They are posted here as a resource, but the material covered in them may differ what the material covered this quarter, and their structure may differ from this quarter's final exam.

Final Exam 2016
Final Exam 2016 Solutions

Winter 2009
Winter 2011 Practice Final

Homework Assignments

Submission Instructions and Policies

Regrade Policy

Recitations

We hold recitation sections in order to review some of the material and solve additional exercises with the students in smaller groups. The sections are optional but highly recommended. The schedule (including locations) of the recitation sections appears in the office hours calendar. Each section covers the material of the previous week except for Friday sections that cover the material of the same week.

Exercises

Resources

Textbooks

The main textbook we use is:
Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, Clifford Stein, Introduction to Algorithms, 3rd Edition, MIT Press
The book is available online through the Stanford library.

We will also occasionally use:
Jon Kleinberg, Éva Tardos, Algorithm Design, Pearson/Addison-Wesley
Sanjoy Dasgupta, Christos Papadimitriou, Umesh Vazirani, Algorithms, McGraw-Hill Education

Homework Resources

LaTeX Resources

We strongly recommend typesetting solutions to the homework assignments using LaTeX. LaTeX provides a convenient way to produce high-quality documents and it is the standard used for typesetting computer science papers.

Guide: An introduction to LaTeX can be found here. Other guides can be found at Wikibooks and NYU.

Online environments: If you do not wish to install LaTeX, ShareLaTeX and Overleaf are online environments that compile previews of your documents as you type and allow you to share documents with collaborators (this feature won't be useful in this course, though). As a Stanford student, you get a free Overleaf Pro account.

LyX: LyX is a version of LaTeX with graphical interface.

Finding mathematical symbols: The introduction mentioned above contains a table of mathematical symbols in LaTeX. Alternatively, consider Detexify.

LaTeX Homework Template: Here is an example of of a LaTeX document, including several elements (section numbering, pseudocode, tables, images, etc) that you might find helpful.