June 2020
Intermediate to advanced
382 pages
11h 39m
English
The basic idea of insertion sort is that in each iteration, we remove a data point from the data structure we have and then insert it into its right position. That is why we call this the insertion sort algorithm. In the first iteration, we select the two data points and sort them. Then, we expand our selection and select the third data point and find its correct position, based on its value. The algorithm progresses until all the data points are moved to their correct positions. This process is shown in the following diagram:

The insertion sort algorithm can be coded in Python as follows:
def InsertionSort(list): for i in ...