Test yourself on Insertion Sort with exam style questions, marked instantly.
Flashcards that come back just before you would forget them.
A revision plan that remembers what you know and shows what to do next.
See which topics you have nailed and which need another look.
Quiz yourself on Insertion SortGet your flashcardsBuild my revision planTrack my progressDeep Dive: Insertion Sort Trace
Sort [5, 2, 4, 1] into ascending order. The first item, 5, is the sorted part to begin with.
- Key = 2: 5 is larger, so shift 5 right and insert 2. List: [2, 5, 4, 1]
- Key = 4: 5 is larger, so shift 5 right. 2 is smaller, so stop and insert 4. List: [2, 4, 5, 1]
- Key = 1: shift 5, 4 and 2 right, then insert 1 at the front. List: [1, 2, 4, 5]
A list of 4 items needs 3 steps, because the first item starts as the sorted part. A list of 6 items needs 5 steps.
Make this stick
Signing in gives access to all PrepWise features.