Correct Code Press · Book Two

Data Structures by Proof

A Correct Code Framework companion book.

Treat data structures as behavioral contracts that determine lawful movement.

Book Two is the concrete layer: the machinery that makes reasoning physically possible. Learn to see every structure as a contract — what access is guaranteed, what update is expensive, what invariant must remain true — and you stop choosing structures from habit and start proving they are necessary.

Requires Student

Book Two: Data Structures by Proof cover
Structures as behavioral contracts, not containers
Shape decides what becomes lawful
Continues Book Zero and Book One

What You'll Learn

The Concrete Layer Beneath the Reasoning

Book Two is the machinery that makes reasoning physically possible: how memory is shaped, how access behaves, and how structure becomes a proof obligation.

Memory Shape

How a structure arranges information — and what that arrangement makes legal.

Access Behavior

How you find, scan, update, and retrieve under a given shape.

Guarantees + Tradeoffs

What becomes easy, and what becomes expensive, under each contract.

Families of Structures

Arrays, linked structures, hash structures, trees, heaps, and graph representations.

Contiguity Creates Index Math

Shape is not decoration. Contiguity decides how you reach.

Links Create Traversal Cost

References make movement deliberate — and costly where shape forgets.

Ordering Creates Elimination Power

Order is a constraint that enables lawful movement.

Hierarchy Creates Controlled Exploration

Trees organize branching into repeatable structure.

Selection by Proof

Choosing structure as a way to protect correctness — not as a matter of taste.

Bridge to Book Three

Once the machinery is clear, movement becomes execution.

Table of Contents

Fourteen Chapters, Five Movements

From the structure contract through sequential, associative, hierarchical, and graph structures, to the final movement: choosing a structure by proof.

Part I: The Structure Contract
Student Access
1
Structure Is a Contract
Access, update cost, invariant, natural scanners.
Student Access
2
Contiguity, Links, and Cost
Index math vs traversal cost.
Student Access
3
Scanners and Traversal
How shape decides which movements become natural.
Student Access
Part II: Sequential Structures
Student Access
4
Arrays and Dynamic Arrays
Index math and amortized growth.
Student Access
5
Linked Lists and References
Traversal cost as a structural fact.
Student Access
6
Stacks, Queues, and Deques
Disciplined access with bounded entry and exit.
Student Access
Part III: Associative Structures
Student Access
7
Hash Tables and Sets
Direct access as a recorder.
Student Access
8
Trees: The Hierarchy Shape
Ordered branching under an invariant.
Student Access
9
BSTs: Ordering as Power
Ordering enables lawful elimination.
Student Access
Part IV: Hierarchical & Graph Structures
Student Access
10
Heaps and Priority Queues
Priority preserved as an invariant.
Student Access
11
Graphs: Adjacency and Cycles
Choice and consequence in connected worlds.
Student Access
12
Tries: Prefix Structure
Shared prefixes as shared shape.
Student Access
13
Union-Find: Partitions
Connectivity as a partition invariant.
Student Access
Part V: Choosing by Proof
Student Access
14
Choosing a Structure by Proof
Selecting tools from constraints, not from habit.
Student Access

From the Book

How the Method Reads

Stop Choosing Structures

When you can answer what access is guaranteed, what update is expensive, and what invariant must remain true, you stop ‘choosing’ a structure — you start proving the structure is necessary.

Shape Creates Legality

Contiguity creates index math. Links create traversal cost. Ordering creates elimination power. Hierarchy creates controlled exploration. The method of a structure is written in its shape.

See the Framework

Start With the Videos

What Is the Correct Code Framework?

Why CCF starts with intent, structure, and proof before code.

Watch on the video library

Case Files Introduction

How case files turn practice into structured investigation.

Watch on the video library

Correct Code Philosophy

The reasoning-first philosophy behind the framework.

Watch on the video library

Some videos require membership access. Visit the video library to see what's unlocked for your plan.

Who It's For

Book Two is for engineers who want structure to feel inevitable

Developers who reach for containers without a reason
Engineers preparing for interviews who want structure selection to feel certain
Students who memorized data structure APIs but not the contracts
Anyone connecting memory shape to algorithmic correctness
Developers ready for the concrete layer beneath Book One’s reasoning

Where It Fits

Book Zero Is the Required Foundation

Start With Book Zero Learn the detective contract: problem space, answer space, decisions, and proof.
Continue With Book One Build the reasoning system before the machinery arrives in Book Two.
Then the Secret Language Read Book Three to see the same shapes move into every algorithm family.

Unlock the Full Book Library

Data Structures by Proof is included with Student Access, which also unlocks Book Zero and every current algorithm book from Correct Code Press.