algorithms, racing
Sort Race
Four sorting algorithms run on the same shuffled array and race each other to finish first. Each one is written as a step-generator, which means the algorithm hands control back to the page after every comparison or swap so the canvas can draw between steps. The slower O(n²) sorts (bubble and insertion) usually finish well after merge and quick. Bigger arrays make the gap between them more obvious.
Insertion
O(n²)Merge
O(n log n)Quick
O(n log n) avgPress Race to start. Highlighted bars are the indices the algorithm is currently looking at.