BeginnerAbout 10 min

    Selection Sort

    Read the full article on Substack

    6 min read.

    A simple comparison-based sorting algorithm. It divides the list into sorted and unsorted regions, repeatedly selecting the minimum element from the unsorted region.

    Think of it this way: Imagine picking the smallest candy from a jar one at a time. Each time you pick, you scan ALL remaining candies to find the smallest, then swap it to the front.

    3827433982100123456

    Start: each pass selects the smallest remaining value and puts it at the front.

    1/35

    Check your understanding

    Answer from memory before you scroll back up. Pulling an idea out of your head is what makes it stay there.

    One pass of selection sort

    Sequence

    Order what happens in a single pass.

    Tap a piece, then tap where it goes — or drag it. Tap the tray to take one back.

    1. 1Drop a step here
    2. 2Drop a step here
    3. 3Drop a step here
    4. 4Drop a step here
    5. 5Drop a step here
    5 pieces left to place

    Quiz

    20 questions
    Question 1 of 20
    Score: 0

    How many swaps does Selection Sort perform in the worst case?

    Done with this lesson?

    Sign in free to keep your progress, streak and quiz scores.

    Keep going