Skip to main content
Stanford
Computer Science
5 credits

Stanford CS 161: Design and Analysis of Algorithms

CS 161 is Stanford's core algorithms course: asymptotic analysis, divide and conquer, randomized algorithms, sorting and selection, hashing, trees, dynamic programming, greedy algorithms, and graph algorithms. It's the course technical interviews are downstream of, and a hinge point of the CS major.

Fennie is independent and not affiliated with Stanford University. This is an unofficial study guide.

What makes it hard

The deliverable changes again: design an algorithm for a problem you've never seen, prove it correct, and analyze its runtime, all under exam time pressure. Dynamic programming is the famous wall because it can't be pattern-matched from a small set of examples. Students who treat psets as the studying, rather than practicing cold design, get exposed on exams.

What you'll cover

  • Asymptotic analysis and recurrences
  • Divide and conquer
  • Randomized algorithms
  • Hashing and data structures
  • Dynamic programming
  • Greedy algorithms
  • Graph algorithms and shortest paths

The CS 161 study guide

How to study for Stanford CS 161, step by step.

  1. 1

    Keep CS 103's proof muscles warm

    Correctness arguments (induction, exchange arguments, invariants) carry half the credit on psets and exams. If proof-writing got rusty since 103, rehab it in week one.

  2. 2

    Design cold before reading solutions

    The exam skill is facing an unfamiliar problem and producing an algorithm. For every practice problem, struggle genuinely before consulting anything. Reading solutions builds recognition, not design.

  3. 3

    Give dynamic programming structured volume

    DP yields to a ritual: define the subproblem in words, write the recurrence, identify base cases, order the computation. Run that ritual on many problems; it's the unit that decides most grades.

  4. 4

    Learn algorithms as design patterns

    For each technique, know the problem signature that suggests it: what makes a problem smell greedy versus DP versus divide-and-conquer. Exams test the choice as much as the execution.

  5. 5

    Simulate exam conditions before each exam

    Timed, closed-book design problems are their own skill. Practice producing correct-and-analyzed algorithms in forty minutes, because the exam measures design speed, not just ability.

Today

Today's CS 161 plan

Preview
65 min

What a Fennie Daily Plan looks like for CS 161. Yours is built from your own syllabus and adapts every day to your deadlines and progress.

0 / 4 done~65m remaining
Keep this plan free

First plan free, no card required. Fennie is independent and unaffiliated with your school.

FAQ

Is CS 161 hard?

It's a definitive core course: exams hand you unfamiliar problems and grade the algorithm, the proof, and the analysis. Dynamic programming is the standard wall. Students who practice designing from scratch, not rereading solutions, separate decisively from those who don't.

How do I get good at dynamic programming in CS 161?

Ritualize it: define the subproblem in English, write the recurrence, state base cases, determine evaluation order. Then apply the ritual to many problems of increasing strangeness. DP is learnable volume-by-volume; it just can't be crammed.

Does CS 161 help with coding interviews?

Directly. Interview questions are largely CS 161 material at lower rigor. The course's design-and-justify habit transfers better than grinding problem lists, though you'll still want implementation practice on top.

More Stanford courses