Skip to content
Roadmap

A roadmap for data structures and algorithms

The 150 problems fall into 18 topics, drawn as 6 lines like a transit map. Ride each line from its first station, and change lines where a topic builds on one from another line.

Foundations

The three basic containers, in order: an array, then one end of it (a stack), then nodes joined by pointers.

Search & scan

Two indexes over an array. A window is two pointers moving the same way, and binary search halves the range between them.

Trees

A tree node is a list node with two next pointers. A trie is a tree keyed by letters, and a heap is a tree packed into an array, which shortest paths need.

Graphs

Backtracking is a depth-first walk over a tree of choices. Graphs are the same walk when nodes can lead back, and weighted graphs arrive where the heap does.

Optimization

Dynamic programming is backtracking that remembers answers. Greedy is the case where one choice is always safe, and intervals are sorted, then swept greedily.

Math & bits

It needs nothing past arrays, so it branches off the first station.