The Future of Sorting Algorithms

Sorting algorithms are an integral part of computers today, and their widespread use means that their efficiency is important. They can be used to sort search results for a user in order of how much they would like them or put a list in alphabetical order. A more straightforward example used to model how sorting algorithms work is sorting numbers. Given a random list, the algorithm can compare and reorder the elements to sort them, and different methods will have different strengths and weaknesses.

One of the most basic examples of a sorting algorithm is bubble sort. It works by first taking the two first elements of the list and comparing them. Then they are rearranged with the higher element to the right. Now, with this new list, they do the same for the next adjacent pair of numbers, and so forth. From this, the highest element will be at the rightmost position where it belongs. This makes sense because the highest element is always moved to the right, so the highest element will end up “bubbling” up to the top. Then, you restart from the bottom, bubbling up the second-highest element, until all elements are in their correct places.

While that sort is intuitive and somewhat easy to visualize, it can get very slow at large scales, so more efficient methods of sorting must be developed. One such efficient method is known as quick sort. Quick sort works by first choosing a pivot element, then comparing it to every other element, and putting all elements greater than it to the right, and all less than it to the left. Then within these groups, it chooses a pivot element and does the same, dividing itself into as many groups as needed until it is sorted. This method of sorting has been regarded as one of the fastest sorts.

Recently, an AI called AlphaDev created by DeepMind, the same company responsible for the chess bot AlphaZero, managed to create a sorting algorithm significantly faster than its human competition. One advantage the bot had was its ability to code in assembly. Assembly is the language that is at the base of computers, having commands to move around the individual bits on a chip, and it allows you to make incredibly fine-tuned and precise algorithms but is also difficult to learn and use. However, since AlphaDev is a computer with lots of time, it was able to use assembly to make code 70% faster than the existing method. At the moment, the code it’s making is for small-scale sorting, but with more time and changes to the way the code works, AlphaDev and other AI coding bots could revolutionize the way computers function beyond just sorting. 

MIT Tech Review

Originally published on:
June 23, 2023