Skip to content

DSA Bible

A personal textbook for the data-structures & algorithms ideas that don't click the first time.

Each chapter explains one hard idea slowly: the intuition first, then the code, then an interactive demo you can step through line by line, then the usual ways people get it wrong. When something confuses me in the future, it gets a chapter here.

How to read this book: don't just read the demos, poke them. Step backwards, load weird trees, try to predict the next step before you click. The confusion goes away once you can predict what happens next.

Start here

Try it right now

The widget below is the main tool of this book. Press ▶ Play (or click inside it and use ← →) and watch how a tree works out its own height: nobody knows the answer at first, and the answers are passed back up from the bottom.

Colour key used in every tree demo

Colour Meaning
amber the call that is running right now (top of the call stack)
indigo a call that is paused, waiting for a child to answer
green a call that has finished; its answer is in the badge
∅ an empty child (None). Calls on it still happen; that's where the base case runs.