Sorting Race
The same row of bars is sorted five different ways at once. Count the comparisons and moves to see which method is fastest.
- Bubble Checks 0 ・ Swaps 0
- Insertion Checks 0 ・ Swaps 0
- Selection Checks 0 ・ Swaps 0
- Quick Checks 0 ・ Swaps 0
- Merge Checks 0 ・ Writes 0
Step 0
A simplified teaching model: 16 bars, each comparison or move counted once.
How to play
The height of a bar is its number. Your goal is to see which of five methods puts the bars in order, shortest on the left, with the least work. First pick a starting order with the buttons at the top. Press "Start" and all five methods run at the same speed. Looking at two bars to see which is bigger is a "compare", swapping two bars is a "swap", and each one is one step. "Step once" lets you go at your own pace. Methods are ranked by who finishes in the fewest steps. Try "Nearly sorted" and "Reversed" and watch the ranking change.
Learn more
Bubble compares neighbours and swaps them. Insertion slides each bar into its place. Selection carries the smallest remaining bar to the front. Quick splits the bars around a pivot bar, smaller ones on the left. Merge sorts halves and then combines them. For nearly sorted bars, insertion is fast; for reversed bars, bubble and insertion struggle while quick and merge do well. Merge counts "writes" instead of swaps. The counts here are for 16 bars; real programs with long lists show far bigger gaps. A simplified teaching model.