IntermediateAbout 20 min

    Quick Sort

    Read the full article on Substack

    6 min read.

    A highly efficient Divide and Conquer algorithm. It picks an element as pivot and partitions the given array around the picked pivot.

    Think of it this way: Imagine a teacher lining students up by height. She picks one student (the pivot) and says: 'Shorter to the left, taller to the right.' Now she has two smaller groups and repeats. Much faster than moving one student at a time!

    3827433982100123456

    Start: pick a pivot, move smaller values left of it, then sort each side.

    1/39

    Check your understanding

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

    Partition around a pivot

    Sequence

    Order one level of quick sort (Lomuto partition).

    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

    What is the "Partition" step in Quick Sort?

    Done with this lesson?

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

    Keep going