How the counts on this site work
Every figure beside the animation comes from counting operations while the algorithm runs, with the same rules for all 23 algorithms. This page is the ledger: what each counter includes and leaves out, how the strip chart and sound are made, how time is measured on your own device, and what none of it can tell you.
Where the numbers come from
Algorithms never touch the array directly. They go through a small interface with a few actions: read a cell, write a cell, swap two cells, compare, and read or write a helper buffer. Each call adds one to a counter and, while recording, appends one event to a trace. The animation then replays that trace, and the counters you watch rise are tallied from the replayed events, so the picture and the totals cannot disagree.
The input is a shuffled list of the numbers 1 to n, so every value is distinct. The size goes up to 1000, and lower for the slowest algorithms: bogo sort stops at 7 elements and stooge sort at 150. If a run produces more than about four million events, the page skips the animation and shows only the totals and the final result.
Comparisons
A comparison is one question asking whether one element is smaller than another, and each question adds one. Only element-against-element checks count. Loop conditions, index arithmetic, checks of a flag such as whether anything was swapped, and the digit arithmetic of radix sort are free. Comparing the same two elements twice counts twice, so the number is exactly how often the algorithm asked.
That is why counting sort reports only n minus 1 comparisons, spent finding the largest value, even though it clearly does a lot of work. The work shows up as reads and writes instead.
Reads and writes
A read fetches a value from the array and a write stores one. The Reads and Writes counters include helper buffers: reads of the main array and of any auxiliary buffer are added together, and so are writes. Merge sort's buffer therefore appears as extra reads and writes, which is the honest price of its extra memory. Creating a buffer is not counted, and neither is the recursion stack.
A comparison made by position, such as is element i plus 1 smaller than element i, first reads both elements, so it adds two reads and one comparison. A comparison between values already held in variables adds only the comparison.
Swaps, counted once
A swap exchanges two cells and counts as one swap, with no reads or writes added, although real hardware does two loads and two stores. The rule keeps swap-based algorithms recognisable. On 1000 shuffled elements bubble sort reports about 250,000 swaps and no writes, while insertion sort, which shifts elements one place instead, reports about 250,000 writes and no swaps. Both numbers are close to the count of out-of-order pairs.
So when you compare algorithms of different styles, add swaps and writes together, and remember that a swap moves two elements at once.
The bars and the strip chart
The bars show the array, with height equal to value. In the default theme compared bars flash blue and swapped bars red, and a written bar is drawn hollow; each mark fades in about 150 milliseconds. Beside the bars, the strip chart is a rolling log. Time runs to the right with the newest events at the right edge, and the position down the chart is the array index, with index 0 at the top.
A compare is two blue dots joined by a line, a swap is two larger red dots joined by a thicker line, and a write is a short vertical tick. Reads are not drawn. A compare of plain values, with a position missing, is drawn between the two most recent reads. At high speed one column holds every event of a frame, up to 16 marks with swaps and writes kept first, and the chart keeps the latest 120 columns. A dense strip is therefore a sample, while the counters stay exact.
Real time and visual time
Real time is measured on your device, not computed. After you press Play or Step, the algorithm is run again with no recording, on copies of the same input, in batches that double in size until a batch lasts at least 20 milliseconds or a quarter of a second has passed, with at most 1024 runs per batch. The mean of the last batch is shown. The run includes the counting overhead and happens in a browser, so it measures this implementation, not a compiled one.
Visual time is the stopwatch of the animation. It grows only while playing and depends on the speed slider, so it says how long the show takes, not how fast the algorithm is.
Sound, and what counts cannot tell you
With sound on, one triangle-wave tone plays. The value at the last array read, write or swap of each frame sets its pitch, from about 200 Hz for the smallest value to 1000 Hz for the largest. The tone follows values, not positions, and comparisons and helper buffers make no sound.
Operation counts are not seconds. They ignore cache behaviour, branch prediction, memory allocation and the cost of a comparison function. Quick sort scans memory in order, which caches love, while heap sort jumps around; a branch that mispredicts half the time can cost more than an extra read. Use the counts to understand growth, use real time as a hint from one device, and benchmark your own data before deciding.