1.2.13

Insertion Sort

Test yourself

Insertion Sort

Insertion sort is a simple sorting algorithm, which is very intuitive.

Illustrative background for The conceptIllustrative background for The concept ?? "content

The concept

  • Imagine sorting a deck of cards.
  • Hold the deck of cards in one hand, and place a single card down on the desk.
  • Take a card from the top of the deck in your hand, and put it in the correct place in the other deck.
  • Repeat until all the cards are gone.
Illustrative background for In EnglishIllustrative background for In English ?? "content

In English

  • Take the second card:
    • Compare to the first card, swap if needed.
  • Take the third card:
    • Compare to second card, swap if needed.
    • Compare to first card, swap if needed.
  • Take the fourth card:
    • Compare to all previous cards.
  • Repeat for all cards.
Illustrative background for Pros and cons of insertion sortIllustrative background for Pros and cons of insertion sort ?? "content

Pros and cons of insertion sort

  • Pros:
    • Easy to implement.
    • Little memory used.
  • Cons:
    • Not very efficient.

Jump to other topics

1Computational Thinking & Algorithms

2Programming

3Hardware & Software

4Data

5The Internet

6Online Safety & Security

Go student ad image

Unlock your full potential with GoStudent tutoring

  • Affordable 1:1 tutoring from the comfort of your home

  • Tutors are matched to your specific learning needs

  • 30+ school subjects covered

Book a free trial lesson