Lanes
Starting order
How to play
- Pick 2 to 4 sorts for the lanes. They all get the same bars.
- Press Race!. Every lane makes the same number of moves per second.
- Turn the sound on and listen: you can hear each one work.
| Do this | Phone | Keyboard |
|---|---|---|
| Race / Pause | Race! button | R |
| New bars | New bars | N |
| Sound on / off | Sound button | M |
| Number of lanes | 2 / 3 / 4 | 2 3 4 |
| Sorts, order, bars, speed | Menus, buttons, sliders | Tab to them |
What's happening?
- A computer sorts by comparing two things and maybe swapping them. That's all it can do.
- Bubble, insertion and selection sort compare almost every pair. Double the bars and they get about 4 times slower.
- Merge, quick and heap sort split the job up. Double the bars and they get only a bit over 2 times slower.
- The start matters: insertion sort flies through nearly sorted bars, but crawls on reversed ones.
- The sound's pitch follows the height of the bar being looked at.
Try this: race bubble against merge with 20 bars, then with 120. How much bigger does the gap get? Then try insertion sort on "Nearly sorted".