Enhancing the Quality of Life with Algorithms

The world functions on algorithms. Right from the computer and the smartphone in our hands, to the decisions we make, and while even finding a life partner, we use the power of algorithms to make like simpler, easier and much, much better.

Algorithms To Live By (2016) by Brian Christian and Tom Griffiths shows how we can use different algorithms in life and how these algorithms can be put to practical use in our daily lives.

Problem Solving

We already know that computers run on algorithms. Every output or problem it solves is due to an algorithm that is fed into it. 

The term ‘algorithm’ actually dates back to the 9th century, when the Persian mathematician Muhammad al-Khwarizmi first coined it. However, they were used only about 4000 years ago during the Sumerian civilization. To define an algorithm, it is a ‘finite series of steps that help solve a problem’.

Thus, everything around us can be considered an algorithm. When we follow the instructions in a recipe or following the instructions of a board game– all can be considered as algorithms.

While jotting down a list of pros and cons to choosing a job or thinking systematically to make a decision, one uses intuitive algorithms. However, by nature, intuitive algorithms aren’t precise. For example, making a decision to start a new business venture is an algorithm, however, it is used in a time of uncertainty for comprehending the best outcome.

Hence though intuitive algorithms differ from mathematical algorithms, they serve the same purpose – to solve a problem. The criteria one puts in place while choosing an apartment and the step-by-step actions one takes to meet them require processes akin to a computer to solve problems and arrive at solutions.

Algorithms To Live By (2016) by Brian Christian and Tom Griffiths
Algorithms To Live By (2016) by Brian Christian and Tom Griffiths

The Optimal-Stopping Algorithm

Let’s consider searching for an apartment. One often finds it tough to decide when to keep searching or when to stop. One’s judgement is often clouded by the first apartment one sees, perceiving it as the best option available. However, the second option could seem better in retrospection. The optimal stopping algorithm can solve such a conundrum.

Mathematically, the optimal stopping algorithm looks at the first 37 out of 100 options, without choosing any. The idea is to then establish a standard that emerges. For example, the standard could be that an apartment that has 3 rooms, placed on floors above the fifth, etc. Out of the 37, the first apartment that meets the criteria should be considered. While it doesn’t guarantee the best option, the optimal odds are much better than simply guessing. This rule of 37 can be applied to practically anything.

Math unfortunately doesn’t indicate when one should stop. In a simple coin flip of a triple or nothing strategy, the bet triples with each flip, or one risks losing all that they have won. Thus if one starts with $4, with odds of fifty-fifty, one can either win $12 or lose it all. Averaging it out, one can expect to end up with $6. In the next round with $12, one can hope to win $18 on average and so on.

Hence, mathematics doesn’t tell when to stop betting if we consider odds and averages. Sooner or later, one can stand to lose all ending the betting game. A purely mathematical algorithm thus doesn’t help in every situation.

Multi-Armed Bandit Problems And Upper Confidence Bound Algorithm

At a slot machine in a casino, while many choose to wait to hit the jackpot eventually, others choose to explore different options and use the information to their advantage.

However, in other situations such as investing or dating, one faces the dilemma of how long to keep losing till one hits jackpot. How does one arrive at a winning strategy then?

These are multi-armed bandit problems in math and they can have many different answers. At the casino slot machines, the easiest approach to improving odds is “stay-win, lose-shift.” This, however, won’t always be the best strategy. The strategy states that one should stick to one machine till one loses. However, a one-time loss cannot be the indicator of how one’s luck turns out.

The Upper Confidence Bound algorithm is a better option in such cases.

Using this algorithm, one chooses the machine that provides the best-expected value of playing. One thus chooses the machine with the biggest jackpot based on information from the jackpot counter. Then, one keeps track of how much one wins, and whether the wins are gradually increasing or decreasing than expected. If the outcome is continually disappointing, then one should move to the second-biggest jackpot slot machine and so on.

This algorithm considers that a good machine can still result in a loss, thus increasing one’s chances of winning.

Adaptive clinical trials in the pharmaceutical industry are also an example of how multi-armed bandit problems can be solved. During drug testing for ailments, doctors keep evaluating subjects and make on-the-fly changes to the testing plans. If the drug doesn’t seem to work, they immediately focus on another drug that worked too. They keep testing, trying, and eliminating even before the trials are over or before results are in.

Sorting Using The Bubble Sort, The Insertion Sort And The Merge Sort

Everyone has been through the situation where they are unable to find a file or books once they clean the mess in their office shelves. Not only do these take up a lot of time and energy, but leave one exasperated at not finding things when they are most needed. Algorithms can be applied to mundane chores like sorting files and books too.

The least efficient algorithm, the Bubble Sort, involves organizing one pair of things, one time, again and again, till everything is sorted. For instance, while alphabetically sorting books in a library, one can start with going through the shelves starting with “A”. 

If there are two books starting with ‘A’ already in place, one puts them in alphabetical order. So ‘A Guide To Eating Right’ is placed before ‘Alice In Wonderland’. Then one comb through the entire collection, gathering books starting with ‘A’, and places them alphabetically before, after, or in between these two books. The same procedure is then used for all other alphabets.

This method is, however, extremely time and energy-consuming. One can then choose to use the Insertion Sort. In this method, one simply takes out all the books and puts them back, one by one, in the alphabetically right order as compared to the ones that have already been put in.

The third method, the Merge Sort algorithm, involves dividing all books into piles, sorting the piles alphabetically, and then putting them alphabetically in place by merging all the piles.

Data Organization

Computers sort and file data in a hard drive, or in a solid-state drive (SSD). Hard drives can store more data, whereas SSD’s are quicker and efficient in getting the data one requires. Today, there are devices that combine the advantages of both, thus helping in faster data retrieval and making more space to create archives. However, the most frequently used and most important data is stored in the upper layer of memory called the cache.

Computers are able to choose what data gets stored in the cache. It uses the algorithm Last Recently Used (LRU) that stores the information last used at the top of the cache. The LRU is an easy way for computers to guess which data will be needed most in the future.

This method thankfully can be used for letters, bills and other important papers too, that one needs to keep handy. This method is perfect for those who choose to keep clutter on their desk. The most important papers are already on the top of the desk!

The human brain works in a similar fashion too, when one has a tough time remembering unused information. Thus, for a presentation, or an exam, reading up notes right before one sleeps can make the information easily accessible.

Design algorithms for your life

Scheduling With Algorithms

Scheduling and organising one’s time is an effective strategy for success. Meeting, and remembering to meet deadlines on time can be a challenge. Algorithms can be used for this purpose as well.

The Earliest Due Date algorithm helps when one is juggling multiple tasks. It involves starting with the task that has the closest deadline.

Moore’s Algorithm is used when time is running out and one knows that all tasks cannot be completed in time. Moore’s algorithm involves skipping the tasks that will take the most time to complete, thereby, giving one more time to complete other tasks. With this method, overall, more tasks can be completed.

However, with these algorithms, one should be wary of priority inversion, where minor, unimportant tasks take up all the time, leaving one with no time for completing more important tasks. Additionally, one must remember that there are no quick-and-easy or sure-shot methods to solving the majority of the time-management, scheduling problems.

Moreover, one has to be careful that the actions of scheduling or organizing tasks themselves can take up a lot of one’s time.

Thankfully, there is a simple method one can use to get as much as possible done in the shortest amount of time. This method involves a lot of focus and ignoring any distractions such as texts or emails. The act of switching between work and mails or messages takes up time and energy, requiring the brain to start the thinking process afresh. Focus always helps finish work faster, without worrying about where to start.

Algorithms Can Help Predict Future Outcomes

While no one can accurately predict the future, algorithms can be used to predict probable outcomes. Known as forecasting, this method has its roots in 18th century England when Reverend Thomas Bayes found a basic way to predict the probability of future events such as drawing a winning lottery based on certain prior events.

For example, in lottery scratch tickets, one wants to understand what proportion of the tickets in circulation can offer a win for the 3 tickets purchased. According to the Reverend, one has to start by hypothesizing about the prevalence of winning tickets in circulation and using this as an assumption, one can calculate the probability of the results actually seen in the three tickets. Thus if all 3 tickets win, one can assume that all tickets in circulation offer a win – that is a 100% win all the time. If only half of the tickets win then one only has a 12.5% chance of winning.

The more information one gathers, the more precise the hypothesis is.

Over the years, math has given the world precise tools to make predictions. Those predictions then depend on the distribution pattern of a phenomenon. If we look at the bell curve that is modelled on normal distribution, it can be applied to many phenomena. For example, the bell curve assumes that in an age demographic, there are few very young or very old people, whereas most middle-aged people fall in the middle of the bell. Hence, a person will definitely not go on a blind date with people falling on either end of the bell curve’s spectrum.

Some other situations follow the power-law distribution. In this algorithm of averaging, one reaches the median average by having most observations fall below it, whereas the most enormous ones fall above. For instance, considering wealth distribution, there are more poor people in the world, whereas the lion’s share of the world’s wealth is in the hands of a select few!

Managing Data Overload And Exchanging Messages

Let’s consider a scenario where two generals, each standing atop two adjacent hills separated by a valley, plan to attack a city fortified by the valley. They need to communicate with each other about the exact time of their intended, coordinated attacks. If they send messengers across the valley, the messengers will get caught exposing their plan. How can they hence, communicate their plans to each other?

Computer scientists have been trying to solve such conundrums and find ways to communicate messages using algorithms. One such algorithm, the retransmitted till breakdown method, works by sending in messenger after messenger, until the message goes across, a method similar to when a person repeatedly calls or messages a friend until they get a reply. 

Today, one faces different problems while getting messages across. For example, an error due to an overloaded server could stop messages from reaching the intended recipient.

The exponential backoff method can then prove to be helpful. If an overloaded server is blocking messages or emails, this method advises waiting, for say 2 minutes, instead of hitting the refresh button over and over again. If the same error occurs, double the waiting time to four minutes, and keep doubling the waiting time till the message goes through.

Ideally speaking, everyone should use the exponential backoff method. However, it is seen that the additive Increase, Multiplicative Decrease (AIMD) method is useful too. It helps one understand the maximum load of data a server can handle. The algorithm first sends one package of data, and then doubles the amount subsequently, till the point of overload.

It then pinpoints the limit just before the overload and after that, it sends the highest amount of data, increasing the load by just a tiny amount till the limit is reached.

Algorithms Help Guiding Decisions

A scenario in game theory best explains how algorithms can help predict what people will do in certain scenarios.

Let’s consider 2 bank robbers who have looted a bank, are called in for questioning and are placed in separate rooms. Both are aware that the cops don’t have enough evidence against them. If both keep shut, all the cops can do is give both a 1-year prison sentence on a lesser charge. 

However, the police offer both the prisoners a deal to testify against the other. If the first robber testifies and the other remains quiet, the first robber goes free while the other gets a 10-year sentence. If both testify against each other, both get a 5-year sentence. How would 2 rational individuals respond to such a situation?

Rationally speaking, both would testify against each other, with the hope that the other remains silent. However, both testifying against each other becomes an inevitability. The maximum reward – the possibility of escaping a sentence – is what lures both the robbers and both testify against the other. While a five-year sentence is better than a ten-year sentence, it is still the cops who have a win-win situation.

Another algorithm called the mechanism design works to force a behaviour from people rather than give them options at all.

For instance, the company Evernote faced the problem of employees not availing of their vacation time. Being aware that well-rested employees are more productive than overworked ones, the company even offered a $1000 bonus to those who used their vacation time. However, that plan didn’t work either.

The mechanism design algorithm, if used in this case, simply takes away the option of using the vacation or not. It makes taking time off mandatory!

Limitations Of Algorithms

Algorithms can be used in many fields and they have proved to work well. However, it is imperative to know and understand that algorithms too have limitations.

  1. Not all algorithms work all the time. for example, while understanding the cause of obesity, one has to consider a number of factors including, genetics, unhealthy lifestyles, lack of exercise, etc. Simply focusing on a diet won’t work. Hence one would need a complex algorithm than a simple one.
  1. The complexity of an algorithm can be a limitation too. Applying algorithms to real-world problems can prove to be difficult. One has to factor in uncertainties and errors in data. One would ideally want to start with a sample data set, build an algorithm to make predictions, and even add variables and errors to make it perfect. This is called overfitting and can cause a problem when applying it to a different data sample.
  1. Perfect algorithms don’t exist. The travelling salesman problem poses the question of how to find a single route between multiple points without requiring to go to any location more than once. If the designated area spans an entire country, the algorithm becomes complex, and there is no perfect solution. Hence the only choice is, relax one standard and settle with ‘good enough’ rather than ‘perfect’.


Algorithms aren’t limited to computers and mathematics. They can be used, and are used in day-to-day life. Humans are mostly unaware that they are applying an algorithm.

Algorithms help in problem-solving and contain a lot of wisdom that can help in making decisions. They can even help in predicting possible outcomes and help people enhance their general productivity.