Skip to content
ReadMe Daily

Search articles, problems, patterns and every cheat sheet topic.

Algorithm Visualiser

Give an algorithm your own data and watch it work, one step at a time, with the line of code responsible highlighted beside it and a sentence explaining every move.

Run them side by side

Pick a group and every algorithm in it runs the same input in step. The counters under each one turn the difference between them into a number instead of an impression.

All six sorts running on the same shuffled array. Press play and watch the comparison counts separate: the n log n sorts finish while the others are still halfway.

At n = 14, the curves on the cards are worth n log₂n ≈ 53 and n² = 196. The counters are exact counts for this one run, so a count can sit above its own curve — that gap is the constant factor Big-O drops. Pull the size slider and watch which counters keep up.

  • AverageO(n²)
    Comparisons
    0
    Writes
    0
    for scale
    n² = 196

    Sort 14 bars by repeatedly swapping neighbours that are the wrong way round.

  • AverageO(n²)
    Comparisons
    0
    Writes
    0
    for scale
    n² = 196

    Find the smallest bar left, put it next, repeat.

  • AverageO(n²)
    Comparisons
    0
    Writes
    0
    for scale
    n² = 196

    Grow a sorted run on the left, inserting one bar into it at a time.

  • AverageO(n log n)
    Comparisons
    0
    Writes
    0
    for scale
    n log₂n ≈ 53

    Split the array down to single bars, then merge the pieces back in order.

  • Quicksortstep 1
    AverageO(n log n)
    Comparisons
    0
    Writes
    0
    for scale
    n log₂n ≈ 53

    Pick a pivot, move everything smaller to its left, then sort each side.

  • Heap Sortstep 1
    AverageO(n log n)
    Comparisons
    0
    Writes
    0
    for scale
    n log₂n ≈ 53

    Read the array as a binary tree: the children of index i are at 2i+1 and 2i+2. Build a max-heap, then take the top repeatedly.

All 17 visualisers

Each one has its own page, with the full-size picture, the code, controls for building your own input, and a written explanation of what it is doing and why.

Sorting

Six ways to put the same bars in order. The counters are the point: they turn “n² is worse than n log n” into a number you can watch grow.

Searching

Finding one value in an array. Sorting first costs something, and these show exactly what it buys you.

Pathfinding

Four searches across a grid you draw yourself. They differ in one line — which cell comes out of the waiting list next — and that line changes everything.

Data structures

Build up a sequence of operations and watch the structure respond to each one, with the cost of every operation shown as it happens.