23
Insertion Sort
A fun sorting algorithm is insertion sort. Have you ever played cards and needed to sort the cards in your hand (Figure 23-1)?
The approach you (or your canine friend) use to sort a playing card from one part of your hand and move it to the other part is nearly identical to how insertion sort works. It is actually a tad more exciting than that sounds, so let’s look at how insertion sort works.
Onward!
How Insertion Sort Works
The way insertion sort works is sorta kinda really cool. The best way to understand it is by working through an example. We formally describe ...
Get Absolute Beginner's Guide to Algorithms: A Practical Introduction to Data Structures and Algorithms in JavaScript now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.