September 2019
Intermediate to advanced
816 pages
18h 47m
English
The insertion sort algorithm relies on a simple flow. It starts from the second element and compares it with the element before. If the element before is greater than the current element, then the algorithm swaps the elements. This process continues until the element before is smaller than the current element.
In that case, the algorithm passes to the next element in the array and repeats the flow, as in the following diagram:

The time complexity cases are as follows: best case O(n), average case O(n2), worst case O(n2)
The space complexity case is as follows: worst case O(1)
Based on this flow, an implementation for primitive ...