A complete, free course on data structures, from asymptotic analysis and pointer arithmetic all the way to CRDTs, learned indexes, and the storage engines behind Spanner and Kafka.
📖 Read it online: dnakhoa.github.io/everything-data-structures
Five volumes · 31 chapters · 4 appendices · ~55,000 words · Python, C, C++, Java and Go examples.
Written by Ngoc Anh Khoa Doan, with the editorial help of Claude.
Also by the author: Frontier LLM Engineering — a free field guide to how frontier language models are actually built, with exercises and runnable labs.
Most data structure resources stop at red-black trees. This one keeps going, through competitive-programming machinery (link-cut trees, wavelet trees, Mo's algorithm), through research-grade structures (FM-indexes, succinct trees, fractional cascading), and out the other side into system design, where the central claim of Volume V is that a routing table is a trie, consistent hashing is a hash ring, and a message queue is a persistent FIFO. Systems are data structures composed at scale.
Every chapter covers the same ground: the idea, the invariants, the operations with complexity analysis, working code, real-world usage, and the historical context of who invented it and why.
You do not have to read this front to back. Pick the track that matches what you're doing.
Never studied data structures formally, or want a clean rebuild of the fundamentals.
| # | Chapter | Why it's here |
|---|---|---|
| 1 | The Philosophy and Mathematics of Data Structures | Big-O, amortized analysis, the no-free-lunch tradeoff |
| 2 | Primitive Types and Memory Organization | What a pointer actually is |
| 3 | Arrays | Contiguous storage, dynamic resizing |
| 4 | Linked Lists | The other way to store a sequence |
| 5 | Stacks and Queues | LIFO, FIFO, and what they're for |
| 6 | Tree Fundamentals and Binary Trees | Traversals, representations |
| 7 | Binary Search Trees | Ordered data, and how it degrades |
| 9 | Heaps and Priority Queues | The workhorse of scheduling |
| 12 | Hash Tables | O(1) average, and the fine print |
Finish with Appendix A: Complexity Cheat Sheet.
The structures that actually come up, plus the judgment to pick between them.
Track 1, then:
- Chapter 8: Self-Balancing Trees. AVL, red-black, splay, treaps
- Chapter 11: Graphs. BFS/DFS, topological sort, MST, shortest paths, union-find
- Chapter 13: String Data Structures. Tries, suffix arrays
- Chapter 14: Probabilistic Data Structures. Bloom filters come up constantly
- Chapter 25: Complete Selection Guide. The decision matrix
- Appendix B: When to Use What
Assumes you know the fundamentals and want the contest arsenal.
- Chapter 23: Advanced Competitive Programming Data Structures. The big one: segment trees with lazy propagation, Fenwick trees, heavy-light decomposition, link-cut trees, Mo's algorithm, suffix automaton, eertree, wavelet trees, Li Chao trees, sparse tables, Cartesian trees, sqrt decomposition, DSU with rollback
- Chapter 10: Multiway Search Trees and B-Trees
- Chapter 21: Algorithm Design Using Data Structures
- Chapter 24: Research-Grade Data Structures. When you want to go past the standard set
For backend, infra, and system-design work.
- Chapter 10: B-Trees. Why every database index is one
- Chapter 16: External Memory and Cache-Oblivious Structures
- Chapter 17: Persistent Data Structures
- Chapter 18: Concurrent Data Structures
- Chapter 27: Distributed Data Structures. DHTs, consistent hashing, CRDTs, consensus, quorums
- Chapter 28: Network Topology and Routing
- Chapter 29: System Design as Data Structure Composition
- Chapter 30: Advanced System Patterns
- Chapter 31: Real-World Case Studies. Spanner, Dynamo, Kafka, Delta Lake, Cloudflare
- Appendix D: Network and System Design Quick Reference
Part 1: Mathematical Foundations
Part 2: Fundamental Linear Structures
- Arrays—The Foundation of Contiguous Storage
- Linked Lists—The Art of Distributed Storage
- Stacks and Queues—Ordered Access Patterns
Part 3: Hierarchical Structures and Trees
- Tree Fundamentals and Binary Trees
- Binary Search Trees
- Self-Balancing Trees
- Heaps and Priority Queues
- Multiway Search Trees and B-Trees
- Probabilistic Data Structures
- Spatial and Geometric Data Structures
- External Memory and Cache-Oblivious Structures
- Persistent Data Structures
- Concurrent Data Structures
- Emerging and Specialized Structures
- Data Structure Design Patterns
- Algorithm Design Using Data Structures
- Practical Considerations
- Advanced Competitive Programming Data Structures
- Research-Grade Data Structures
- Complete Selection Guide and Complexity Reference
- Distributed Data Structures
- Network Topology and Routing Data Structures
- System Design as Data Structure Composition
- Advanced System Patterns and Case Studies
- Real-World Case Studies
- Synthesis and Future Directions
- A. Complexity Cheat Sheet
- B. When to Use What
- C. Glossary
- D. Network and System Design Quick Reference
- Bibliography
The site is mdBook. To preview with live reload:
cargo install mdbook && mdbook serve --openEvery chapter is also plain Markdown, so you can read the whole course on GitHub without building anything.
Corrections, clarifications, and better examples are welcome. Open an issue or a pull request; each page on the site has an "edit this page" link that takes you straight to the right file.
Prose is licensed CC BY 4.0; code samples are MIT. Use it in your class, your study group, or your blog. Just credit the source.