About

About

The Algorithm Guide explains classic algorithms and data structures in Java. Each guide takes one algorithm, shows how it works step by step, and ends with a Java implementation you can run, change and break.

Why This Guide Exists

I use this guide to learn algorithms properly myself. Writing an algorithm down, tracing it by hand and then implementing it is the best way I know to understand it, rather than only well enough to copy an example.

That shapes how the guide is written:

  • Every algorithm is traced, not just described. The visualizations follow the Java code line by line, so you can see what each pointer, swap and recursive call does.
  • Complexity comes first. Each guide states the best, average and worst case in time and space, and explains when each case happens.
  • The code is plain Java. The implementations use the standard library only, so you can paste them into any project or JShell and run them.

How Each Guide Is Laid Out

Every guide follows the same layout:

  1. Introduction: what the algorithm does and the key ideas behind it.
  2. Performance Characteristics: the time and space complexity in the best, average and worst case, and when each happens.
  3. Algorithm (Pseudo Code): the algorithm without Java syntax getting in the way.
  4. Visualization: a step-by-step trace on a small example, aligned to the Java code.
  5. Java Code: the implementation, one method at a time, each with an explanation.
  6. Summary: the key points to remember.

Start from the Guide List and pick an algorithm. Trace the example yourself before reading the visualization: working it through on paper teaches more than reading about it.