TALLMOVE
All arcs

Sorting

Swaps of neighbours to the hybrids libraries run: bubble, selection, and insertion sorts, gaps that shrink, halves merged, a pivot, a heap, the runs Timsort stitches, digits sorted in passes, and a network of comparators that sorts with no branches.

Algorithms & Data Structures

Start: Bubble Sort
Progress0/10

Before you start

Some lessons here build on lessons from other arcs: Heaps & Priority Queues.

  1. 1

    Bubble Sortin progress

    Algorithms · Sorting · ~15 min

    Watch the real library implementation sweep the array again and again, swapping neighbors until a pass finds nothing left to swap.

  2. 2

    Selection Sortin progress

    Algorithms · Sorting · ~15 min

    Watch the real library implementation scan for the smallest remaining bar and swap it to the front, one final position per pass.

  3. 3

    Insertion Sortin review

    Algorithms · Sorting · ~20 min

    Watch the real library implementation execute line by line while it grows a sorted prefix through the array.

  4. 4

    Shellsortin progress

    Algorithms · Sorting · ~20 min

    Watch the real library implementation insertion-sort the array at shrinking gaps, so far-apart bars move long distances in one hop.

  5. 5

    Merge Sortin progress

    Algorithms · Sorting · ~25 min

    Watch the real library implementation split the array down to single bars, then merge sorted halves back together through one auxiliary buffer.

  6. 6

    Quicksortin progress

    Algorithms · Sorting · ~25 min

    Watch the real library implementation partition the array around pivots that land in their final slots and never move again.

  7. 7

    Heapsortin progress

    Algorithms · Sorting · ~25 min

    Watch the real library implementation turn the array into a max heap, then retire the maximum to the end again and again.

  8. 8

    Timsortin progress

    Algorithms · Sorting · ~30 min

    Watch the real library implementation find natural runs, extend short ones with binary insertion, and merge them under the stack rules that keep it fast.

  9. 9

    Radix Sortin review

    Algorithms · Sorting · ~25 min

    Watch the real library implementation sort three-digit values without a single comparison: bucket by ones, then tens, then hundreds.

  10. 10

    Sorting Networksin progress

    Algorithms · Sorting · ~30 min

    Watch Batcher's odd-even merge network sort the array with a fixed schedule of compare-exchanges that never looks at the data to decide what happens next.