data strucutures and algorithms in Java
A hands-on workbook for mastering data structures and algorithms from the very first principles. It pairs a readable mdBook (theory, complexity proofs, edge cases) with Java skeletons and JUnit 5 tests you implement yourself.
This repo ships blank on purpose: skeletons with TODOs, failing
tests, and prompts to fill in. The answers are yours to write.
Each module folder under src/ holds:
notes/NN-<topic>.md— the mdBook pages (numbered in reading order).code/NN-<Class>.java— the Java skeletons you implement.problemset/ProblemNN.java— one stub per problem.tests/concepts/*Test.java— JUnit 5 tests for the topic skeletons.tests/problemset/*Test.java— JUnit 5 tests for the problem set.PROBLEM_SET.md— the module's problems (Foundational + Applied).extra-practice/— generated on demand by/extra-practice(problems + stubs + tests); not shipped, gitignored archives aside.
All .java files use the default package (no package line) and are
compiled per module — flat and dependency-free. Topic skeleton classes are
package-private so the numbered filenames compile.
AI tooling. The repo is built to be worked with an AI coding agent as a
tutor. Guard + teaching protocol live in one canonical AGENTS.md (the other
agents' files symlink/import it); Claude Code skills are in .claude/skills/
(portable copies in .agents/skills/); and a zero-dependency MCP server in
mcp/ exposes teach_topic / generate_extra_practice to any
MCP agent. See Learning with AI.
18 modules, 112 topics. Each topic is a fill-in-yourself lecture outline (concept → time & space complexity → implementation walkthrough) paired with a Java skeleton and JUnit 5 tests — except a few concept/proof topics that are notes-only.
Module 0 — Foundations · 5 topics
Module 1 — Arrays · 4 topics
Module 4 — Recursion & Divide and Conquer · 6 topics
Module 5 — Searching & Sorting · 13 topics
Module 6 — Trees · 7 topics
Module 7 — Heaps & Priority Queues · 4 topics
Module 9 — Disjoint Sets · 4 topics
Module 10 — Graph Fundamentals · 10 topics
Module 11 — Graph Algorithms · 9 topics
Module 12 — Hash Tables · 6 topics
Module 13 — Dynamic Programming · 9 topics
Module 14 — Greedy Algorithms · 6 topics
Module 16 — Tries · 4 topics
Module 17 — Advanced · 13 topics
- Java 21 + JUnit 5, built with Gradle (Kotlin DSL).
- The Gradle wrapper (
./gradlew) downloads Gradle and pulls JUnit from Maven Central, so a JDK on yourPATHis all you need to install.
You can run the book locally using mdbook. The roadmap on the intro page is a
Mermaid diagram, so you also need the
mdbook-mermaid preprocessor. Install both via cargo:
cargo install mdbook mdbook-mermaidRun the book locally to preview it in your browser
mdbook serve --openNOTE: Math (recurrences, bounds, proofs) renders via MathJax, and the roadmap renders via
mdbook-mermaid.
./gradlew test # compile + test every module
./gradlew test_06-trees # just one module (task name == folder name)Each module gets its own isolated Gradle source set and test task, so the
duplicate default-package class names across modules (every module has its
own Problem01, etc.) don't collide. ignoreFailures keeps the build green
so every module runs and reports.
Tests fail initially — that's the point. Implement a skeleton until its tests go green.
Style is enforced by editorconfig-checker
against the root .editorconfig (LF endings, final newline, no trailing
whitespace, tab indentation for .java). Run the exact same check CI runs:
./gradlew lintThe checker binary is fetched into build/tools/ on first use, then run with
.editorconfig-checker.json. It exits non-zero and lists file:line for any
violation, so run it before you push.
Work this with an AI coding agent (Claude Code, Cursor, Copilot, Codex, Gemini, Windsurf, Aider) — but as a tutor, never an autocomplete. The repo ships guard files that put any cooperating agent into tutor mode: it teaches and grades, but never fills in your notes, code, or problems. Full guide: Learning with AI.
Per topic:
- Learn it —
/teach <topic>(or "teach me<topic>"): a section-gated lecture that stops after each section until you understand it and have written that section's notes in your own words. - Implement the
code/skeleton until./gradlew test_<module>passes. - Get reviewed — "review my passing code for edge cases, don't fix it."
- Drill the module's
PROBLEM_SET.md— Foundational cold, then Applied. - More reps —
/extra-practice <module>(or "more problems on<topic>") generates fresh problems + stubs + tests intosrc/<module>/extra-practice/. - Space it out and check the topic off in
TODO.md.
The teach + extra-practice flows work in any agent three ways: the instruction
files (zero setup), the zero-dependency MCP server in mcp/
(approve once), and Claude Code skills (/teach, /extra-practice).
The main repo holds only the blank skeletons (the template).
- It is marked as a GitHub Template Repository
- Click "Use this template" to create a standalone repo of your own — not a fork, no "forked from" link, clean history, its own repo Public or private, your choice. Fill in your answers there
ci.yml— compiles every module and runs./gradlew test. Tests run informationally (ignoreFailures) since the template ships unimplemented, so the build stays green on the blank workbookdeploy-book.yml— builds and deploys the book to GitHub Pages on push tomain. Enable via Settings → Pages → Source: "GitHub Actions"
See TODO.md for the full module/topic checklist.