AlgoViz

Insertion sort

easy 14 min

Insertion sort builds a sorted prefix one value at a time: it takes the next value, shifts every bigger value in the prefix one slot right, and drops the value into the gap.

Check yourself

One question at a time. Each answer explains why.

Question 1 of 10

Score 0
applied

What is the minimum number of comparisons insertion sort needs to sort [1, 2, 3, 4, 5]?

Pick an answer to see why.

Flashcards

Say your answer, then reveal it.

Card 1 of 11

Recall

What does insertion sort do on each pass?

Say your answer, then reveal it.

These cards come back in Today, just before you would forget them.