See how we make computers work smarter, not harder, with visualized sorting algorithms

If you’re new to programming, your first exposure to the concept of “algorithms” may be the challenges you faced in freeCodeCamp. While they’re a great introduction, you may be wondering, “Why am I doing this?”, “Why should I be interested in this topic?” or, “What could there possibly be to studying algorithms in computer science?”. To answer this question, I like to turn to visualizations, and today I found a video that I think is worth your time.

First, some background. In the early days of computing, a major motivation for the study of algorithm design was the sorting of arrays. This is something we take for granted when using a high-level language because we can just call myArray.sort() and be done with it. What we might not understand is that computers don’t just know how to sort an array of numbers, that an array is out of order, or certainly how to sort arrays quickly. Arrays can be incredibly large, and small amounts of time spent on each item will add up. So, imagine that you have 1000 papers in a neat stack to be filed alphabetically. Think about what strategies you might use to sort the paper as you watch this (You may want to mute it and set the speed to 1.25x or even 1.5x). Remember that all of these are running on the same hardware.

This isn’t meant to teach you any new skill or applicable knowledge. We get so used to hearing about improvements in hardware, that we forget about the speed of software, and I’d like to impress that importance on you. Just look at how much faster quick sort is. Imagine how much slower your fancy, super powerful personal computer(s) would be if all the software they ran was written like bubble sort.

5 Likes

Nice. No wonder my computer runs so bad.

I remembered doing this a few months ago. I had to sort piles of numbered papers (I don’t know how many sheets there were in the largest piles). One pile took around 4 hours to sort with merge sort :slight_smile: