ArraysLesson 7Free preview
DSA Insertion Sort
This lesson is part of DSA · All levels
Summary
The insertion sort is similar to the way humans arrange cards in their hands: the elements are taken one by one and then inserted into the correct position among the elements that have already been sorted. On almost sequential data, this algorithm is very fast because of the slight shifts that occur. However, on large-scale random data, the complexity remains.
Key points
- Building the left-to-right sequence of elements one by one
- Very efficient for small or nearly sequential data
- In-place, no memory required as large as an array
- Average and worst complexity, best
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.