The video starts by describing two common sorting algorithms; “bubble sort” and “insertion sort.” In the former, a sorting algorithm repeatedly steps through a list that needs to be sorted, compares each pair of adjacent items in turn, and then swaps them over if they happen to be in the wrong order. In the latter, new items are constantly “inserted” into previous sublists for an ever-growing search pile.
Both will work for this problem, but are less than efficient if time is of the essence.
The optimal answer, it turns out, is something called “quicksort,” which is regularly used by programmers for a variety of different applications — from sorting items by price to showing you the closest gas station on a GPS map.
To sort your pile of books the quicksort way, begin by taking a book from roughly the middle of the shelf. This becomes your “partition” book, and by sorting everything on its left and right into
Once this is done, you then add partition books to the middle section of the two smaller piles, and then keep doing this until you have multiple partition
Simple, right? Sure, it’s a pretty basic bit of computer science translated into the real world, but we bet that you’ll never think about alphabetizing in quite the same way again.
Now if we could only stop spending hours watching such “life hack” videos, we might actually get something done a bit more efficiently around here!
- How to move Windows 10 to an SSD
- How to share an external hard drive between Mac and Windows
- The best gaming Easter eggs of all time
- Download audiobooks for free at these websites
- How to install fonts on a Mac