This simulator sorts eight tagged values one step at a time, highlighting each comparison and moving swapped values along separate arcs so their identities stay visible. You pick the algorithm and the starting order and compare the work each does.
• A 3D scene with tagged value columns, comparison brackets, operation counters and an order and inversion indicator. • An Algorithm selector (bubble, insertion, selection) and an Initial order selector (mixed, sorted, reverse). • Readouts for comparisons, swaps, progress (algorithm-specific confirmed prefix or suffix length), array length and remaining inversions. • Restart demonstration and Advance event buttons, and experiments for sorted input, selection on reversed input and insertion on reversed input.
An inversion is a pair in the wrong order; a sorted array has zero inversions. Bubble sort compares adjacent pairs so the largest values settle to the right and it stops early when a pass makes no swaps: on sorted input it needs seven comparisons and zero swaps. Insertion sort moves the next value into a sorted prefix, and on reversed input needs twenty-eight comparisons and swaps. Selection sort finds the smallest remaining value and swaps it into place, and needs twenty-eight comparisons regardless of initial order. Watching the counters across the three orders shows how input shape matters.
The array has eight deterministic values. Insertion sort uses adjacent swaps for visualization rather than a shift-optimized implementation, and bubble sort includes early termination. Timing is event playback, not benchmark performance, and the progress marker is an algorithm-specific count rather than a universal percentage.
No. Real performance also depends on data size, memory behavior and implementation. The lab counts comparisons and swaps, not time.
Zero. No later value is smaller than an earlier one, which is the condition the remaining-inversions readout reaches at the end of every run.
Because it always scans the whole remaining region to find the minimum, regardless of whether the data is already in order — twenty-eight comparisons for eight values.
It includes early termination: a full pass with no swaps means the array is sorted, so it finishes after seven comparisons and zero swaps.