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 planWhat 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
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
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
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
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
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
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 freeMore Stanford courses
CS 106A — Programming Methodology
CS 106A is Stanford's famous introduction to programming, taught in Python — control flow, functions, decomposition, lists, dictionaries, and graphics — assuming zero prior experience. Its lectures and assignments are public, and through Code in Place it has been taught free to hundreds of thousands of people, so it's studied worldwide by enrolled students and self-learners alike.
CS 106B — Programming Abstractions
CS 106B follows 106A with programming abstractions in C++ — recursion, ADTs and the standard collections, big-O, linked structures, trees, and hashing. It's the course where Stanford CS gets real, and like 106A its materials are public and heavily used by self-learners.
CS 107 — Computer Organization and Systems
CS 107 takes students from C++ down to the machine: C programming, pointers and memory, bit-level representation, x86-64 assembly, and how the heap actually works — culminating in the famous heap allocator assignment. It's the systems gateway of the Stanford CS core.
CS 103 — Mathematical Foundations of Computing
CS 103 is Stanford's discrete math and theory gateway — proof techniques, set theory, induction, graph basics, then finite automata, regular languages, and the first look at computability and P vs NP. For most students it's the first course where the deliverable is a proof, not a program.