Data structures explained

The shapes data is stored in, and why the right shape turns a slow question into a fast one.

18 conceptsBeginner to Intermediate

Every data structures concept

Data structuresIntermediate

Merkle trees

Hash the hashes, and prove one leaf without the rest.
OPEN LESSON
Data structuresBeginner

Arrays

One block of memory, instant access by index, and costly inserts in the middle.
OPEN LESSON
Data structuresIntermediate

Gap buffers

The array with a hole at the cursor that makes typing cheap.
OPEN LESSON
Data structuresBeginner

Deques

A queue open at both ends: add or remove at the front or the back in one step.
OPEN LESSON
Data structuresBeginner

Circular buffers

A fixed array reused as an endless loop, with a head and a tail that wrap round.
OPEN LESSON
Data structuresBeginner

Hash sets

A bag of unique keys that can tell you in one step whether an item is inside.
OPEN LESSON
Data structuresBeginner

Binary trees

Nodes with a left and a right child, the shapes they form and how tall they get.
OPEN LESSON
Data structuresIntermediate

Heaps

A tree in an array that keeps its smallest value on top through inserts and removals.
OPEN LESSON
Data structuresBeginner

Priority queues

A queue where the most urgent item leaves first, and the heap that makes it fast.
OPEN LESSON
Data structuresBeginner

Tries

A tree of letters where words that start the same share the same path.
OPEN LESSON
Data structuresIntermediate

Fenwick trees

Running totals that survive updates, using the lowest 1 bit of each index.
OPEN LESSON
Data structuresBeginner

Adjacency list vs adjacency matrix

Two ways to store a graph, and what each costs in memory and lookups.
OPEN LESSON
Data structuresBeginner

Directed acyclic graphs (DAGs)

One-way arrows and no loops: the shape of anything that has dependencies.
OPEN LESSON
Data structuresIntermediate

Bloom filters

A row of bits that says “definitely not” or “probably yes” without storing anything.
OPEN LESSON
Data structuresIntermediate

K-d trees

Cut space in half, again and again, to find the nearest point without checking them all.
OPEN LESSON
Data structuresIntermediate

Rope data structure

A tree of small text pieces that keeps edits to huge files cheap.
OPEN LESSON
Data structuresIntermediate

Suffix arrays

Sort every ending of a text once, then find any word in it by binary search.
OPEN LESSON
Data structuresIntermediate

Splay trees

A search tree that rotates whatever you just used up to the root.
OPEN LESSON