2.1.15

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.
  • You'll keep all the sorted cards at the top of the deck, take the next unsorted card and compare it with all the sorted ones from the front until you find the correct place to insert it.
Illustrative background for In EnglishIllustrative background for In English ?? "content

In English

  • Always assume the first card is sorted, since there are no other values to compare it to.
  • Take the second card and compare it to the one on top. Swap if needed.
  • Take the third card. Compare it with the one on top, then with the second one. Insert it in the correct place.
  • Take the fourth card. Compare it with the one on top, then with the second one, then with the third one. Insert it in the correct place.
  • Repeat until you have sorted all cards.

Jump to other topics

1Computer Systems

1.1Systems Architecture

1.2Memory & Storage

1.3Computer Networks, Connections & Protocols

1.4Network Security

1.5Systems Software

1.6Ethical, Legal, Cultural & Environmental Concern

2Computational Thinking, Algorithms & Programming

2.1Algorithms

2.2Programming Fundamentals

2.3Producing Robust Programs

2.4Boolean Logic

2.5Programming Languages & IDEs

Unlock your full potential with Seneca Premium

  • Unlimited access to 10,000+ open-ended exam questions

  • Mini-mock exams based on your study history

  • Unlock 800+ premium courses & e-books

Get started with Seneca Premium