The Fastest Way To Alphabetise Your Bookshelf

If you have a lot of books on your bookshelf, alphabetizing it by author or title will make it easier to find specific books in the future. Here's the fastest way to do it.

In this video from the TED-Ed YouTube channel, software engineer and educator Chand John explains how a simple sorting algorithm can get your bookshelf organised in no time. It's called "QuickSort," and it's used by programmers in all kinds of applications. Online stores use it to sort items by price, and GPS maps use it to show you the nearest gas stations.

Start by pulling one book from the center of your shelf. This is your partition book. Compare every book on the shelf to your partition book, then place every book that goes before it on the left, and every book that goes after it on the right.

Now select another partition book in the middle of each partition and go through the same sorting process as shown in the video. You should be left with books all fairly close to where they need to be, and you can sort the rest with only a few swaps. Of course, if you're not into alphabetising, there are other ways to plan out your bookshelves.

What's the fastest way to alphabetize your bookshelf? [YouTube]


    Only if the books are quite out of order. If the books are already in order, or almost except say one, it would be the worst method to use. It is however a very good way of understanding quicksort.

    I very much doubt that any website uses quicksort to find the closest 'gas' station. Did you plagiarise? :) Spatial searching is not really the forte of quicksort, let alone route finding. You want the 'nearest' petrol station that you can drive to, so Dijkstra's algorithm, A* search are the more likely candidates, but there are much better ones available based on A*.

    Last edited 30/11/16 10:44 am

Join the discussion!