Be the algorithm
You are the sort. Pick the two values it swaps next, or say it is done. Every round has new values, so the only way to win is to follow the rule, not to remember the answer.
- Bubble SortWalk left to right comparing neighbours, and swap a pair that is out of order. After each pass the largest unsorted value has reached its place; a pass with no swaps ends the sort.Play a round
- Selection SortFind the smallest value in the unsorted part and swap it to the front of that part. If it is already at the front, there is no swap.Play a round
- Quick SortPartition around the last value, the pivot: scan left to right and swap each value smaller than the pivot to the end of the left side (no swap when it is already there), then swap the pivot in after the left side. Sort the left part, then the right.Play a round
- Heap SortFirst build a max-heap: sift down from the last parent back to the root, swapping a parent with its larger child while the child is bigger. Then repeatedly swap the root to the end of the heap and sift the new root down.Play a round