Algorithms are all around us, governing everything from the recipes we use to cook dinner to the routes our navigational systems suggest we take to avoid traffic. But what exactly is an algorithm? In simple terms, an algorithm is a set of instructions for completing a task. The word comes from the name of a 9th-century Persian mathematician, Muhammad Ibne Musa Al-Khwarizmi, who was credited with introducing the concept of algorithms to the Western world. Today, algorithms are used in various ways, from sorting mail to routing internet traffic. And, of course, algorithms power the search engines we use daily.
But how do algorithms work? In short, algorithms rely on the power of an “agent” to rapidly carry out instructions exactly and precisely, processing large amounts of data or identifying patterns quickly. In the case of a cooking recipe, the agent executing the algorithm is a human being. But in the case of a search engine, the agent is a computer system or thousands of computers working together. For example, when you search for a particular term on Google, the search engine uses an algorithm to scour the internet for pages that contain that term. It then ranks those pages based on several factors, like how often the word appears on the page and whether other websites link to that page. The goal is to provide users with the most relevant results possible – thanks to algorithms, we can accomplish the task with speed and accuracy.
But as we’ve pointed out, you don’t have to be a computer to run an algorithm. A human being can run algorithms in their head!
In their book Algorithms to Live By: The Computer Science of Human Decisions, Brian Christian and Tom Griffiths argue that we can use algorithms to improve our decision-making skills. For example, when deciding whether or not to sell your home, you could use the “secretary problem” algorithm. This algorithm helps you optimize your chances of finding the best buyer by spending the optimal amount of time looking for the best offer. It so happens that the optimal time to spend looking for buyers is roughly a third of the time you’ve allocated to completing the sale. For example, say you’ve been given three months to sell your home. It would be best to look at all inbound offers for a month, not accepting any of them. Then, starting with the first day of the second month, you should simply accept the first offer you receive, which is equal to or better than the best offer you’ve received so far. No more waiting, no more dilly-dallying. This is the optimal amount of time to dedicate to “searching.”
Any productivity expert will tell you that determining the order in which you do tasks is vital to getting the most out of your day. For instance, let’s say you’re trying to decide which task to do first: write an article or design a presentation. You could spend hours agonizing over which job is more critical or choose the first option that meets your criteria for importance. Making a quick decision saves time and energy that could be better spent on completing the task. If you have many jobs, should you do a bit of each in a round-robin fashion, i.e., starting one task, working on it for a bit, then switching to another task and repeating until they are all done? Or should you do the shortest one first? Perhaps you should choose the hardest one first? It turns out that ranking tasks by a combination of factors that reflect overall priority is the best approach in most cases. In other words, think of all the factors that go into making the completion of a task valuable. Then rank all the tasks appropriately and do them in that order.
The last-in-first-out (LIFO) algorithm used to manage a computational data structure called a “stack” is another practical algorithm you can use to get things done faster. For example, let’s say you are working on writing a paper or an article and have lots of pieces of paper, research materials, and other sources strewn about on the desk. How should you organize these most efficiently? Well, once again, computer science has an answer! It turns out that you should put these objects in stacks, perhaps separated by topic, where the last item you use is merely put back on the top of the pile. This works because the information most recently accessed tends to be what is most likely to be accessed next. In computers, caches utilize this principle, also called “locality of reference.” What went last in, is most likely to come first out… or LIFO.
Countless other algorithms can increase productivity, but these are great ones to learn more about and an easy place to start. Using optimal explore/exploit approaches, LIFO techniques, and priority-based multi-tasking, you can make better decisions about how to spend your time and get more done.
Algorithms are excellent tools that not only can help us get more done quickly but also in a less stressful manner by allowing us to make rational decisions procedurally and not burdening our minds with on-the-fly decision-making that needs to be thought through from scratch. Everybody can do with a bit of computer science. It makes for a more productive and prosperous life!