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.

Build my CS 161 study plan

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 — 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.

  6. 6

    Train the design reps with Fennie

    Upload your CS 161 syllabus and Fennie's Daily Plan spaces algorithm-design practice across the quarter with DP given double runway, paced to the exam dates, plus quizzes from your actual materials. Free to start.

    Start my CS 161 plan free

How Fennie helps with CS 161

Fennie's Daily Plans space CS 161's design practice across the whole quarter — DP started early, every technique drilled past recognition into production — synced to the exam dates. Chat through why an approach works or where your recurrence breaks, building the cold-design skill that exams and interviews both measure.

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.

Pass CS 161 with a plan, not a cram

Upload your CS 161 materials and Fennie generates a Daily Plan paced to your deadline — plus chat, flashcards, and quizzes built from the actual course content.

Get started free

More Stanford courses