August 2024
Intermediate to advanced
516 pages
11h 47m
English
We’ve previously encountered two different sorting algorithms: Bubble Sort and Selection Sort. Both have efficiencies of O(N2), but Selection Sort is actually twice as fast. Now you’ll learn about a third sorting algorithm called Insertion Sort that will reveal the power of analyzing scenarios beyond the worst case.
Insertion Sort consists of the following steps:
In the first pass-through, we temporarily remove the value at index 1 (the second cell) and store it in a temporary variable. This will leave a gap at that index, since it contains no value:

In subsequent pass-throughs, we remove the values at the subsequent indexes.
Read now
Unlock full access