Grow a sorted part one item at a time, or split the list to single items and merge them back in order.
Insertion sort
An insertion sort treats the first item as a sorted list of one.
Each pass takes the next item and slides it left into the right place in the sorted part.
- Pass 1 inserts the second item, pass 2 the third, and so on: a list of n items takes n - 1 passes.
- Items in the sorted part that are bigger than the new item each move one place right.
- It is quick when the list is already nearly in order.
The rest of this lesson and its 7 practice questions are in Plus.
Screen 1 of 4, free to read.
- 7 exam-style questions, marked as you go, each with a worked solution
- Anything you get wrong is saved to your flashcards