Use Turbo Mode - shift-click the green flag. Click "Generate Array" to generate 24 random numbers from 1 to 20. Then, click "Insertion Sort" to watch Insertion Sort do its thing!
A visualization of insertion sort! I had to implement and benchmark insertion sort for a school project and thought it would be neat to make a visualizer here. :) You can check out a description of the sort in all sorts of places like Introduction to Data Structures and Algorithms by Cormen, Leiserson, Rivest and Stein. In that book, they compare insertion sort to how you'd sort playing cards in your hand; in your hand, you have all sorted cards (starting with just one), and then you pull a card from the unsorted pile and put it into its correct spot in the sorted hand. This sort is stable, which means elements in the array appear in their original relative order after sorting (eg. if you have [0, 0] in your array, the first 0 will still appear first after it's sorted). This doesn't seem important, but in some sorts that rely on a second sorting algorithm it's necessary. For example, radix sort, which sorts based off the digits in a number, requires a stable secondary sorting algorithm, otherwise the array won't actually be sorted properly by the end. It's also an in-place sort, which means all the sorting happens in the original array. This sort has a O(n^2) time complexity, which basically means it's really bad at sorting big data sets. It has a space complexity of O(1), which means you don't really need any additional space to store the data your sorting in the mean time. It's actually really quick here because we're only using 24 numbers - I had to add a couple of delays so you could see it do its thing! Thanks to Geeks for Geeks for helping me out loads when I was taking notes for my midterm! It's how I remember a lot of this stuff. Check out their article here: https://www.geeksforgeeks.org/insertion-sort-algorithm/