The Leanpub 60 Day 100% Happiness Guarantee
Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.
See full terms...

Think. Solve. Build.
Five practical books for going beyond writing C++ code: derive algorithms, tackle 1,000 challenges, investigate real failures, and build an LLM inference engine and a SQL database engine from scratch.
Bought separately
$103
$45.00
About the Bundle
Most programming books teach you a language. This bundle is about what you do with it.
It brings together five practical books built around a single progression: learning to derive solutions, practicing relentlessly, understanding why real code fails, and building substantial systems from scratch.
Deriving Algorithms starts at the hardest point: facing a problem without being told which technique to use. Through full derivations, failed attempts, pivots, and hundreds of problems, it develops the ability to recognize structure and arrive at an algorithm rather than simply recall one.
C++ Algorithmic Mastery turns that reasoning into practice with 1,000 challenges ranging from beginner to legendary.
C++ AUTOPSY takes a different angle: instead of asking only how code should work, it examines how C++ programs actually go wrong and how to reason about those failures.
Then the bundle moves from problems to systems.
Build an LLM Inference Engine in C++ takes you through the construction of a working LLM inference engine from the ground up.
Build a SQL Database Engine in C++ does the same with a database engine, exposing the algorithms, data structures, parsing, execution, and systems thinking behind a real piece of software.
These are not five books that happen to mention C++. They are five different ways of working with code: derive, practice, investigate, and build.
If you want to move beyond knowing how to write C++ and spend more time actually solving problems and building things, this bundle is designed for that.
About the Books
Most algorithm books are catalogues. They present a technique, prove it correct, and give you problems on which to apply it — and they leave out the only part that is hard, which is knowing which technique the problem in front of you wants.
This book is the missing part. Every technique in it arrives at the end of a derivation you can follow: a real problem, an honest attempt that fails, the reason it failed, and the observation that opens it. The name of the technique is withheld until you have already built it, because a name learned before the thing it names is a label rather than an understanding. Nothing here is a catalogue entry. There is no chapter you can skim for a recipe.
Part I builds seven instruments in the order they cost to use — reading a specification, brute force as a starting point, the first engine, invariants, structure that is already there, the state under constraints, and amortised cost — and then closes with a chapter that takes their names away and asks you to choose. Eight chapters. Twenty-seven full derivations. Two hundred and eighty-five problems, each tagged [1] to [5] by how well its ambiguity is hidden rather than by how hard its eventual algorithm is. Every problem sits in one of three layers: a full derivation you watch from the outside, a pivot with the rest left to you, or a statement and a single hint.
Every algorithm in the book has been implemented and checked against a brute-force reference, and every stated measurement has been measured rather than estimated. The ten algorithms of the full derivations appear in Python and C++ in an appendix, cross-checked on two thousand generated inputs each. The book assumes first-year programming — variables, loops, conditionals, functions, arrays — and nothing else.
This book was created through a process that combines careful human planning, content direction, and advanced AI technology, followed by thorough refinement and review to ensure a high-quality final work.
1000 problems. Eight volumes. One complete journey from your very first line of C++ to the frontiers of modern algorithms.
This is the complete collection: 1000 carefully designed C++ problems, organized into 8 progressive volumes that take you from absolute beginner to advanced algorithmic mastery — with every single solution compiled and tested on g++.
What you get:
- 1000 problems, carefully ordered by difficulty across 8 volumes
- A complete, working C++ solution for every problem
- Clear explanations, hints, and complexity analysis throughout
- A structured path, so you never have to guess what to learn next
Every problem includes:
- A clear statement with examples and constraints
- A hint to point you in the right direction
- A full, tested C++ solution
- Time and space complexity
- A plain-language explanation of how it works
The 8 volumes:
1. Absolute Beginner — I/O, Variables, Conditions, Loops, Functions, Arrays
2. Beginner — Strings, Recursion, Basic Math, Simple Data Structures
3. Elementary — Sorting, Searching, Core Algorithms, the STL
4. Upper-Intermediate — Data Structures, Two Pointers, Prefix Sums, Greedy
5. Advanced — Graphs, Dynamic Programming, Trees, Shortest Paths
6. Expert — Advanced Strings, Heavy Graph Machinery, Computational Geometry
7. Master — Suffix Structures, Flow & Matching, Number Theory, Combinatorics
8. Genius — Polynomials & Transforms, Advanced Graphs, Capstone Challenges
Who it's for:
Anyone learning C++ who wants a structured, guided path — students, self-taught programmers, and anyone preparing for coding interviews or competitive programming who wants every step explained, not just a list of problems.
Development Methodology
This book was created through a process that combines careful human planning, content direction, and advanced AI technology, followed by thorough refinement and review to ensure a high-quality final work.
One thousand problems. Eight volumes. A complete roadmap from foundations to mastery.
Every bug in this book passed the compiler. Every bug ran to completion. Every bug returned exit code zero. None of them told the truth.
Most C++ books teach you how to write code. This one teaches you how to investigate it.
C++ Autopsy presents ten forensic investigations into programs that appear perfectly healthy: they compile cleanly, execute normally, and quietly produce the wrong result. No syntax errors. No crashes. No obvious clues. Just evidence waiting to be examined.
Each case unfolds like a real investigation. You begin at the crime scene with a minimal, reproducible program. You examine the evidence, question the suspects—including one deliberate red herring—inspect real diagnostic output from professional tools, identify the true cause, and verify the fix. Every conclusion is backed by the C++ standard, compiler behavior, or observable runtime evidence.
Along the way, you'll uncover some of the language's most deceptive pitfalls: undefined behavior, lifetime errors, memory corruption, concurrency bugs, numerical surprises, optimizer assumptions, and subtle violations of the Standard Library's contracts. Some cases are caught immediately by modern tools. Others pass every warning, every sanitizer, and every test—exactly the kinds of defects that reach production.
Whether you write systems software, libraries, game engines, or high-performance applications, this book will change the way you debug C++. Instead of asking, "Why did my program crash?" you'll learn to ask the more dangerous question:
Development Methodology
This book was created through a process that combines careful human planning, content direction, and advanced AI technology, followed by thorough refinement and review to ensure a high-quality final work.
Why did it appear to work?
For intermediate and advanced C++ developers. Every example compiles with C++20. Every case is real. Every verdict is earned.
Build an LLM Inference Engine in C++ — Through Challenges
You don't truly understand how large language models run
until you've built the engine yourself.
This book takes you from a blank C++ project to a complete,
working inference engine that loads a real Llama-family model
and generates text — one challenge at a time.
What you'll build:
- A strided tensor system with zero-copy views and arena allocation
- Math kernels: RMSNorm, SwiGLU, softmax, GEMM with SIMD
- A byte-level BPE tokenizer
- A full Transformer: RoPE, GQA, Flash Attention, KV Cache
- int8/int4 quantization with direct block multiplication
- GGUF model loading with mmap
- Sampling, streaming, speculative decoding, and continuous batching
- An optional CUDA capstone for the heaviest kernels
By Unit 14, the engine runs a real model on CPU. Every concept
earns its place right after you've built the thing it improves.
Companion Source Code
The complete source code for the book is available on GitHub:
https://github.com/Hatem-M-lab/llm-inference-engine
Development Methodology
This book was created through a process that combines careful human planning, content direction, and advanced AI technology, followed by thorough refinement and review to ensure a high-quality final work.
Who this is for:
C++20 developers comfortable with algorithms
and memory layout who want to understand what actually happens
inside an LLM runtime — not by reading, but by building.
Build a working SQL database engine in C++20 -- from an empty directory to
a query processor that runs real SQL against data on disk -- through a
single relentless method: nothing is asserted; everything is demonstrated.
Every data structure in this book is built, compiled, and run. Every
performance claim is a table printed by a benchmark whose source code is on
the page in front of you. Every design decision is followed by the
measurement that justifies it -- and, where the design has a cost, by the
measurement that exposes that cost too. And once per unit, something fails
in front of you: a real bug, reproduced deterministically, diagnosed from
the evidence, fixed, and locked shut with a regression test.
This is not a survey of database theory. It is a lab manual. You will not
find hand-waving about how B+Trees are "generally logarithmic" -- you will
find the fan-out arithmetic, the page-count math, and a benchmark that
walks a tree of a million keys and prints the real number.
This book takes the engine across two complete parts and eight units:
PART I -- STORAGE
1. Slotted Pages & the Pager -- self-describing 4 KiB pages, records with
stable slot ids, a pager with a free list
2. B+Tree: Insert & Search -- logarithmic lookup, proven against a
million-key tree
3. B+Tree: Delete & Range Scans -- rebalancing, merges, ordered range
queries
4. The Buffer Pool -- a real cache with clock eviction, measured 2.5x
faster with identical logical work
PART II -- FROM BYTES TO A QUERY
5. The Record Layer -- typed rows: a schema-aware codec and a table heap,
reached by key through the index
6. The Catalog -- persistent schemas and named tables: the engine's
self-knowledge
7. The Front End -- a SQL tokenizer and recursive-descent parser, with
compiler-quality caret-pointed errors
8. The Executor -- the milestone: a real executor that runs CREATE TABLE,
INSERT, and SELECT end to end, against a database of hundreds of
thousands of rows
By the last page, the engine answers a SQL query it parsed from text,
against rows it stored on disk, through an index it built and a cache it
manages itself -- and every number in the book came from actually running
that code.
Reference machine: g++ 13.3.0, Ubuntu 24.04, C++20, stdlib + POSIX only.
Every benchmark ships with the exact command that produced it, so you can
run it yourself and get the same structural numbers.
Development Methodology
This book was created through a process that combines careful human planning, content direction, and advanced AI technology, followed by thorough refinement and review to ensure a high-quality final work.
A companion volume, "Build a SQL Database Engine in C++, Book 2: Parts III
& IV," continues the engine into durability (crash recovery via a
write-ahead log), concurrency, and performance -- available separately, and
as a discounted bundle with this book.
Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.
See full terms...
We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.
(Yes, some authors have already earned much more than that on Leanpub.)
In fact, authors have earned over $15 million writing, publishing and selling on Leanpub.
Learn more about writing on Leanpub
If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).
Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.
Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.
Learn more about Leanpub's ebook formats and where to read them
You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!
Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.
Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.