CS265

Welcome to CS265/CME309!

Randomized Algorithms and Probabilistic Analysis

Stanford University, Winter 2026.

Course Overview

Instructor: Mary Wootters

CAs: Spencer Compton, Dorsa Fathollahi

Course Description: Randomness pervades the natural processes around us, from the formation of networks, to genetic recombination, to quantum physics. Randomness is also a powerful tool that can be leveraged to create algorithms and data structures which, in many cases, are more efficient and simpler than their deterministic counterparts. This course covers the key tools of probabilistic analysis, and application of these tools to understand the behaviors of random processes and algorithms. Emphasis is on theoretical foundations, though we will apply this theory broadly, discussing applications in machine learning and data analysis, networking, and systems. Topics include tail bounds, the probabilistic method, Markov chains, and martingales, with applications to analyzing random graphs, metric embeddings, random walks, and a host of powerful and elegant randomized algorithms.

Prerequisites: Prerequisites: CS 161 and STAT 117/118, or equivalents and instructor consent.

When/Where: Class is M/W, 10:30am-11:50pm in CoDa B90.

Office hours.

NOTE: Office hours start in Week 2. There are no OH in Week 1, but please ask on Ed if you have a question.

  • Mary: Tuesday 9-10am, CoDa W216.
  • Dorsa: Wednesday 12:00-2:00pm, CoDa 2nd Floor W253.
  • Spencer: Thursday 1:30-3:30pm, Huang Basement.

Deviations from this schedule will be announced on Canvas.

Course Structure

CS265/CME309 is a "flipped class." This means that you will watch short recorded mini-lectures and/or read lecture notes before class, and come to class ready to engage. In class, we will do active learning to practice and further develop the material from the mini-lectures. The agendas for each class (exercises and solutions) will be posted on this website (in the class-by-class resources below).

Since a large part of learning will happen during active in-class group work, we encourage you to attend class if possible. However, if you can't attend regularly, it is still possible to take this course. If you must do this, we encourage you to find other students in a similar situation to do the in-class work with asynchronously; Ed is a good place to find others.

Exception: Please do not come to class if you are sick.

Announcements

  • Course announcements will be posted on Canvas. If you don't check Canvas regularly, please make sure your notifications are set so that you get email announcements.

Useful Links

Assignments

This course will have (approximately) weekly homework, quizzes, and two in-person exams.

Homework Assignments

    Here are the homework due dates. The homeworks will be posted here as they become available. Homeworks are due on (most) Fridays at 11:59pm on Gradescope. We will post HW at least a week before the due date.

    The homework schedule is listed below. The topics are estimates; in particular, previous material is always fair game :)

    Solutions will be posted on Canvas.

    • Homework 1: (Classes 1,2: The basics, Karger's Alg.). Due Friday 1/16. [problem set] [LaTeX template] [Solutions are available on Canvas]
    • Homework 2: (Classes 3,4: Primality Testing, Markov and Chebyshev). Due Friday 1/23. [problem set] [LaTeX template] [Solutions are available on Canvas]
    • Homework 3: (Classes 4,5: Markov and Chebyshev (again), Chernoff Bounds). Due Friday 1/30. [problem set] [LaTeX template] [Solutions are available on Canvas]
    • Homework 4: (Classes 6-8: Balls and bins, Metric Embeddings). Due Friday 2/6. [problem set] [LaTeX template] [Solutions are available on Canvas]
    • [Break in HW for a week for the MIDTERM! The Midterm covers Classes 1-8.]
    • Homework 5: (Classes 9,10: Probabilistic Method I,II). Due Friday 2/20.
    • Homework 6: (Class 12 (and possibly 9,10 again): More probabilistic method). Due Friday 2/27.
    • Homework 7: (Classes 13,14: Markov Chains). Due Friday 3/6.
    • Homework 8: (Classes 15-17: Martingales) Due Friday 3/13.

Exams

We will have two in-person, proctored exams:

(More) Course Policies

Assignments and Grading

Your grade is made up of:

  • OPTIONAL: 6% of your grade: Attendance. You are allowed five skips to still get full points. You also have the option to shift this fraction of your grade to the midterm/final exam if you can't or don't want to attend regularly. We will automatically choose the option that is best for your grade at the end of the quarter.
  • 28% of your grade: Homework. We will drop the lowest HW score.
  • 16% of your grade: Pre-class quizzes. We will drop the lowest quiz score.
  • 22% of your grade: Midterm. (or 25% if you don't attend class regulary)
  • 28% of your grade: Final exam. (or 31% if you don't attend class regularly)

Note that even though each HW may have a different number of total points, they will be rescaled so that they are out of 100 before averaging them; so all HW count for the same amount. Same goes for the quizzes.

There will be several options throughout the quarter for you to go above and beyond. (For example, bonus "might be fun to think about" problems, links to further reading, etc). These things do not factor directly into your grade, but they will factor into your learning! The course staff will be happy to give you feedback on any of these sorts of things, but we won't officially grade them.

Collaboration Policy

Homework: We encourage collaboration with your classmates in class and on homework! Please acknowledge your collaborators. Note that plagiarism is never okay; anything you or your group hands in should be in y'all's own words.

Quizzes: It's fine to chat with your classmates about the quizzes, but each person should submit their own, and you should (of course) make sure you understand your answers.

Exams: There is no collaboration on the exams.

LLM Policy

We view LLMs like ChatGPT, Copilot, Claude, etc as knowledgeable (if fallible) friends who are not in your homework group. Thus, you are allowed to interact with them the same way as you would with such friends. It's fine to interact with them to build your intuition, get ideas, etc. This can even be a great way to learn, and we encourage that! But you should not have them do or write up your homework for you, just as you should not ask your friends outside of your homework group to do or write up your homework for you.

Academic Honesty

Please follow the Stanford honor code. In this class, the following will be considered violations of the honor code:

  • Having anyone else write up your homework for you, or looking at anyone else's write-up. This includes looking any HW solutions for past offerings of this class that may be floating around. (If you become aware of any such solutions on the internet or elsewhere, please let the course staff know).
  • Consulting anyone other than the course staff, and anything other than your allowed reference sheet, during the exams.
  • Providing help to others in violation of the bullet points above.

Accommodations and flexibility

If you are in a situation that makes the format of this class especially difficult for you, please reach out. We will work with you to make the course work for you as well as we can, while being fair to all students.

Students who may need academic accommodations based on the impact of a disability should initiate the request with the Office of Accessible Education (OAE) and notify us as soon as possible at cs265-win2526-staff@lists.stanford.edu.

IMPORTANT OAE DEADLINES: If you plan to use your OAE-approved exam accommodations for a specific assessment, students must provide their letter and inform the instructor by:

  • 10 calendar days prior to a midterm date.
  • No later than March 2nd, 2026, at 5:00 pm for ALL Winter final exams
  • You only need to submit your letter once per quarter. For urgent OAE-related accommodation needs that arise after the deadline, please consult your OAE adviser. If you are not yet registered with OAE, contact the office directly at oae-contactus@stanford.edu.

Class-by-class Schedule and Assignments

Below, find class-by-class resources, including lecture notes, in-class agendas and exercises, and further reading. All videos can be found Canvas, or also on the YouTube playlist here.

Classes that have not happened yet may have broken links or links to draft (last year's) materials, and are subject to change.

1/5. Class 1: Introduction, Polynomial Identity Testing

1/7. Class 2: Karger's algorithm and the Karger-Stein algorithm

1/12. Class 3: Primality Testing

1/14. Class 4: Markov and Chebyshev inequalities; sampling-based median

1/19. Martin Luther King Day

No class.

1/21 Class 5: Moment generating functions; Chernoff bound; Randomized routing on the hypercube

1/26. Class 6: Balls and Bins; "Poissonization"; The power of 2 choices

1/28. Class 7: Metric Embeddings I; Bourgain's embedding

2/2. Class 8: Metric Embeddings II; Johnson-Lindestrauss Transform

BONUS MATERIAL: Dimension reduction and sparsity: Compressed Sensing; the RIP

    We won't have time this year to get to this (thanks, Monday holidays!), and you aren't responsible for it for this class. However, if you are curious, the videos are available on YouTube for your perusal :)

  • Optional videos and lecture notes:
  • Further (optional) reading:

2/4. Class 9: The probabilistic method I: bounding Ramsey numbers, derandomization via conditional expectations

2/9. Class 10: The probabilistic method II: Second-moment method and the Lovasz Local Lemma

2/11. Class 11: Midterm exam!

IMPORTANT! The exam is 9am-11:50am. You will have 2 hours and 30 minutes to take the exam, and then we have scheduled 20 minutes to collect exams at the end. LET US KNOW ASAP IF YOU CANNOT MAKE (all of) THE EXAM!!!!!

  • Before class: study!
  • During class: exam! See more info in the "Exam" tab.

2/16. Presidents' Day

No class.

2/18. Class 12: Moser's "Entropic Proof" of the Constructive/Algorithmic Lovasz Local Lemma

2/23. Class 13: Introduction to Markov chains; randomized algorithm for 2SAT

  • Before class:
  • During class: Agenda
  • Further reading: Agenda with solutions to in-class work
  • Further reading: Slides with solutions to in-class work
  • Optional further reading: For more about spectral analysis of random walks, see Section 21.1 of Arora and Barak's book "Computational Complexity: A Modern Approach." You can access a digital copy through the Stanford Library: Click Here. Section 21.1 relates the second eigenvalue of the transition matrix to how fast a random walk on a regular graph approaches the uniform distribution (see Lemma 21.3).

2/25. Class 14: Fundamental theorem of Markov chains; stationary distributions; Markov Chain Monte Carlo

3/2. Class 15: Mixing times; strong stationary times; coupling

3/4. Class 16: Martingales; the Doob Martingale; Azuma-Hoeffding tail bounds

3/9. Class 17: The martingale stopping theorem; applications

3/11. Class 18: A taste of pseudorandomness: expanders and extractors