CMU 15-122: Principles of Imperative Computation
15-122 teaches imperative programming with correctness front and center — contracts, loop invariants, and reasoning about code in the C0 teaching language before transitioning to real C — covering data structures from stacks and queues through hash tables, trees, and graphs. It's the second course of the CMU CS core.
Fennie is independent and not affiliated with Carnegie Mellon University. This is an unofficial study guide.
Build my 15-122 study planWhat makes it hard
The course demands two fluencies at once: writing working code and proving it correct with preconditions, postconditions, and invariants. Students who can hack out working solutions but can't articulate why they work lose exactly the points 122 is designed to award. The late-semester transition to real C — pointers, memory, undefined behavior — compounds onto the reasoning workload.
What you'll cover
- • Contracts: pre/postconditions and assertions
- • Loop invariants and correctness reasoning
- • Arrays and searching/sorting
- • Stacks, queues, and linked structures
- • Hash tables and trees
- • C and memory management
The 15-122 study guide
How to study for CMU 15-122, step by step.
- 1
Learn to love the contracts early
Invariant-writing feels like bureaucracy until it starts catching your bugs — usually around week four. Practice writing pre/postconditions for small functions from day one; the skill is most of the course's grade surface.
- 2
Articulate why before running
For every loop you write, state the invariant and convince yourself it holds before testing. 122's exams ask for the reasoning explicitly, and it can't be reverse-engineered from working code under exam time.
- 3
Drill the data-structure operations on paper
Hash table inserts, tree rotations, heap operations — exams test them by hand with the reasoning attached. Draw the before-and-after for every operation type until it's mechanical.
- 4
Respect the C transition
When the course moves from C0 to real C, the safety rails vanish: pointers, casts, and undefined behavior arrive together. Re-do early exercises in C and learn what valgrind output means before the assignments require it.
- 5
Start assignments early — correctness takes passes
A 122 assignment isn't done when it runs; it's done when the contracts are right and the edge cases hold. That second phase takes real time, and it's where the points are.
- 6
Build the reasoning reps with Fennie
Upload your 15-122 syllabus and Fennie's Daily Plan schedules invariant practice and data-structure drills paced to the assignment and exam dates, with quizzes generated from the actual course material. Free to start.
Start my 15-122 plan free
How Fennie helps with 15-122
Fennie's Daily Plans pace 15-122's double demand — code that works and reasoning that proves it — with invariant practice and data-structure drills scheduled to the exam calendar. Chat walks through why an invariant holds or where your contract leaks, building the articulation skill the exams grade explicitly.
FAQ
Is 15-122 hard?
It's a serious step up from 112: you're graded on proving code correct, not just making it work, and the late transition to real C adds memory management on top. Students who practice writing invariants from week one — rather than treating them as paperwork — handle it well.
What language does 15-122 use?
C0, a safe teaching subset of C designed at CMU with built-in contract support, transitioning to real C in the final stretch. The progression is deliberate: learn correctness reasoning with rails on, then apply it where the rails come off.
How do I prepare for 15-122?
Arrive with 112-level programming genuinely fluent — the course spends its difficulty budget on reasoning, not syntax. Early on, over-invest in writing contracts and invariants for simple code; it feels slow and it's the entire game by midterm season.
Pass 15-122 with a plan, not a cram
Upload your 15-122 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 CMU courses
15-112 — Fundamentals of Programming and Computer Science
15-112 is CMU's famous fast-paced introduction to programming in Python — control flow, functions, data structures, recursion, OOP, and efficiency — ending in an open-ended term project. Its public course website and the related CMU CS Academy platform give it a search footprint far beyond Pittsburgh.
15-110 — Principles of Computing
15-110 is CMU's gentler introduction to computing — Python programming plus computing concepts like data representation, algorithms, and the limits of computation — designed for students who aren't CS majors or who want a runway before 15-112. It's one of the largest courses on campus.
15-150 — Principles of Functional Programming
15-150 teaches functional programming in Standard ML — types, recursion and induction, higher-order functions, and reasoning about programs as mathematical objects — alongside 15-122 in the CMU CS core. For most students it's the first time programming and proof become the same activity.
15-213 — Introduction to Computer Systems
15-213 is the famous CS:APP course — data representation, x86-64 assembly, caches, memory, linking, exceptions, virtual memory, and concurrency, taught through the legendary lab sequence (bomb lab, attack lab, cache lab, malloc lab, shell lab, proxy lab). Its textbook and materials are used worldwide, making it one of the most-searched CS courses on the internet.