Insertion Sort
Last updated
What is Insertion Sort?
Insertion sort is a simple sorting algorithm that works by iteratively inserting each element of an unsorted list into its correct position in a sorted portion of the list. It is like sorting playing cards in your hands. You split the cards into two groups: the sorted cards and the unsorted cards. Then, you pick a card from the unsorted group and put it in the right place in the sorted group.
- Start with the second element as the first element is assumed to be sorted.
- Compare the second element with the first if the second is smaller then swap them.
- Move to the third element, compare it with the first two, and put it in its correct position
- Repeat until the entire array is sorted.
Free resources to learn Insertion Sort
- CourseInsertion Sort
- ArticleInsertion Sort Visualization
More in stage 9: Graph Data Structures
Insertion Sort: common questions
Can I learn Insertion Sort in Hindi?
This lesson is written in English. Once you sign in, open it in the interactive course and ask the AI tutor to explain Insertion Sort in Hindi or Hinglish. The tutor answers from this lesson’s own text, so it stays on the syllabus, and it runs on your own Google, OpenAI or Anthropic key.
Is this Insertion Sort tutorial for beginners?
It is lesson 47 of 107 in the free Data Structures & Algorithms roadmap, in stage 9, Graph Data Structures. If you are new to Data Structures & Algorithms, start from stage 1 and come back here in order; if you already know the earlier stages, this lesson stands on its own.