Insertion Sort – Revisited

Insertion Sort implements an algorithm similar to ordering a hand of cards in ascending order. The algorithm is O(n^2) execution and typically is useful when sorting a rather small number of elements.

Several years ago (November 03, 2016) I generated the post Insertion Sort in this blog. The code snippets do not look nice. It seems that the tool I was using to format source code is no longer working as expected. Continue reading “Insertion Sort – Revisited”

Insertion Sort

insertion-sortMoving along in the Algorithms fourth edition book by Robert Sedgewick and Kevin Wayne, I experimented with the Insertion sort algorithm. Visit the https://en.wikipedia.org/wiki/Insertion_sort web site to view an animation of the algorithm. As you can see, it resembles a person arranging playing cards for a game of bridge.

The way the authors described the API to the sorting algorithms allow this one to be quite elegant and compact.
Continue reading “Insertion Sort”