Skip to main content

The ultimate sorting algorithm for alphabetizing your books efficiently

What's the fastest way to alphabetize your bookshelf? - Chand John
We’re suckers for the kind of “life hacks” that tell you that you’ve been doing some relatively mundane task all wrong, and that there’s a super-easy alternative which can massively speed up your ability to perform it.

That’s what a new video from the TED-Ed YouTube channel does, by showing how different sorting algorithms can transform our ability to quickly alphabetize a large number of books on a bookshelf.

Related Videos

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 books which come either before or after it, you instantly reduce the total number of items to search against in sub-piles.

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 books and a bunch of manageable piles to sort. After that, switch to a sorting algorithm like “insertion sort” to get them properly alphabetized.

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!

Editors' Recommendations

This new algorithm can tell how old you are based on your Instagram activity
finstagram fake instagram young people having fun outdoor and making selfie with smart pho

What if we told you that we could tell roughly how old you are based on your Instagram activity? A new algorithm from researchers at Pennsylvania State University apparently can do just that, and what it has shown about how the different generations use Instagram, and social media in general, is quite interesting.

The current generation lives their lives through social media. They use platforms like Instagram to show off their every emotion and mood. According to studies of the Instagram API, teenagers are more likely to interact with photos through likes and comments. However, even though they seem to connect with more posts they statistically post less often than other users.

Read more
New algorithm could help diagnose depression by analyzing the tone of your voice
hotline dating app talking on phone 123rf 45715075 ml

The concept of an AI psychoanalyst has been in circulation for decades, tracing all the way back to Joseph Weizenbaum’s ELIZA chatterbot in the 1970s. But now researchers from the University of Southern California are taking the idea to the next level, courtesy of a machine learning algorithm designed to analyze a person’s speech patterns and help diagnose the possibility of depression in the process.

The tool is part of an ongoing research project called SimSensei, referring to a Kinect-powered virtual therapist able to “read” patient's’ body language for signs of anxiety, nervousness, contemplation and other emotional attributes.

Read more
An algorithm can predict how smart you are based on your Facebook photo
facebook sharing content profilepic algorithm

Admit it: all of us have, at some point or other, judged a person based on their social media profile picture. Whether it’s someone we might wish to date, a prospective employee, or just the dude who disagrees with you in the comments section of a news article, a quick glance at their Facebook picture tells you everything you need to know.

Right? Well, maybe.

Read more