How to read a trace

What the visualizer is showing you, step by step

Every run of your program is recorded one line at a time, then drawn. Two things are worth knowing before you open it: what a single step holds, and what each colour on the canvas means.

01Anatomy of a step

Every step is a complete snapshot of your program.

Not a sketch of the algorithm — a recording of your code. Each step keeps the line about to run, the call stack, every reachable object and the counters, so stepping backwards is exactly as cheap as stepping forwards.

  1. The line about to run

    Highlighted in the editor and named on every panel, so the code, the picture and the numbers always describe the same instant.

  2. Exactly the cells it touches

    arr[j] > arr[j + 1] lights two cells, not the whole array — resolved from the line itself and the live values of j.

  3. Every variable, and what just changed

    Typed the way your editor colours them. A value that moved on this step is flagged on this step.

  4. The whole call stack

    One frame per call, each with its own locals — recursion reads as a column that grows and unwinds.

  5. Running counts

    Comparisons, swaps, reads and writes so far, against the total for the whole run.

  6. Complexity from evidence

    Loop nesting read from your source, cross-checked against how often each line really ran.

02Visual grammar

Four verbs. One colour each, everywhere.

The same hue means the same thing in the editor gutter, on the canvas, in the variables list and on the timeline — learn it once. Each state also carries a glyph, so it reads in greyscale too.

Read

total += arr[i]

A value is looked at. Its cell is outlined — nothing else on the row moves.

Compare

if arr[j] > arr[j + 1]:

Two values are weighed against each other. Both cells lift and are marked ↔.

Write

dp[i] = dp[i - 1] + dp[i - 2]

A position gets a new value — and the cells it was computed from are outlined too.

Swap

arr[i], arr[j] = arr[j], arr[i]

Two positions trade values in one step. Both cells rise and are marked ⇄.

Now

6if arr[j] > arr[j + 1]:

The highlighter. The line about to run in the editor, the node the call stack is standing on in a tree, the vertex being visited in a graph.

Now watch it on real code.

Open the visualizer with your own program, or start from one that already runs.

Browse examplesAlgorithm guides