Everything Can Be An Algorithm

Posted on October 7, 2014

What is an Algorithm?

I think that when most people hear the word ‘algorithm’ they tend to imagine some mathematician or software engineer doing some complex mathematical or computer related task. This is a correct assumption. Mathematicians, programmers, software developers, and engineers all regularly use algorithms to complete various professional and academic tasks. It is algorithms that play a key role in critical developments in science and technology. Algorithms have been and continue to be used in developing the world we live in today. But, I think that people oftentimes do not really understand what algorithms really are, and that their reach extends far beyond the realm of the various aforementioned professionals and significant scientific developments.

So what is an algorithm? Here is a definition from Professor Jeff Erickson from the University of Illinois:

An algorithm is an explicit, precise, unambiguous, mechanically-executable sequence of elementary instructions.

This is one of the first things that I was met with when I took his Algorithms course as a Senior. This definition is great. I like this definition because it captures exactly what an algorithm is in just a few words. However, this definition is still very intimidating. I do not think it helps people move away from the image of the mathematician or software engineer I described above.

Let’s try another definition. The following is my own definition of the word ‘algorithm’. I am going to set aside the rigorous academic requirements for an algorithm and instead focus on what I believe is the very essence of an algorithm, in more simple terms. My definition is as follows:

An algorithm is a sequence of steps that, when followed, will complete a specific task.

This definition is an excellent starting point for algorithmic thinking.

Algorithms Everywhere

I believe that a person can think in terms of algorithms in many different contexts. These are situations and environments that reach far past a academia or a technical job. What I mean by this is that it is possible to think of common day tasks algorithmically.

Why? Well, since I took the algorithms course I mentioned above, my approach to most problems changed. I adopted an algorithmic mindset towards virtually every task I had to perform. I found that thinking about the algorithm involved in executing a particular task is a recipe for great productivity. By doing this, it becomes easier to get started, harder to get distracted, makes mistakes during execution less likely, and can make the actual time the task makes shorter than when not using this mindset.

So what does this really entail? Well just like a computer scientist would do, thinking algorithmically outside of the realm of computers involves breaking a task or problem down to fundamental units, or small steps, and designing a plan or procedure on how to complete these units in order. I find that thinking about the small details of a task helps as well.

For example, suppose that I have to do the laundry. I am sitting in my room, in front of my laptop. I can just think, “well, I guess it’s time to go do my laundry,” and then just go start doing things. There is no doubt that this is an acceptable way for me to do the laundry. In my opinion it just is not ideal.

Suppose I have to get my laundry done, but instead of just deciding to do it, I develop an algorithm to do it. The algorithm to get the laundry done is as follows:

  1. Perform a quick scan of my room for any miscellaneous articles of clothing that are not in the laundry basket.
  2. Pick up every article of clothing.
  3. Put them all in the laundry basket.
  4. Grab the laundry detergent from the closet.
  5. Put the laundry detergent on top of the basket.
  6. Carry the basket downstairs to the laundry room.
  7. Set the washing machine.
  8. Start a timer on my watch for 35 minutes.
  9. Bring the laundry detergent back upstairs, leave the laundry basket.

Another, shorter algorithm, similar to steps 7-9 would follow a while later for setting the laundry to dry. This seems extremely tedious, right? Why bother doing it this way? To begin with, there is no need to actually write down an algorithm like this. This is just something you should lend about 5-15 seconds of thought to, immediately before you begin to perform the task.

The advantages of this approach, in this and most cases are:

  1. Efficiency - By using this approach, I am making a plan that will be at least as efficient as if I just got up and started moving. For example, suppose I forgot my laundry detergent in my closet, and went to the laundry room without it. Now, I have to spend an extra 90 seconds running back to my second floor bedroom and then back down to the laundry room. Not that big of a deal, but could have been avoided with about 10 seconds of planning.
  2. Ease of Execution - This may not be the ideal term, but the general idea here is after acknowledging the specific steps a task takes to get from start to finish, I find that the task ends up appearing substantially easier to execute than just looking at the task holistically. In this case, “doing my laundry” seems very tedious. However, scanning my room is quick, grabbing the laundry detergent is quick, carrying the basket is quick, setting the laundry is quick. Looking at it this way, I have a chain of quick, well defined tasks. This is easier to digest and start working on than a single, ambiguous task.
  3. Focus - The last element of this type of approach I find is that one develops a better sense of focus during the task. No step in doing the laundry is difficult, but it is still possible to make mistakes during the process. For example, setting the load as cotton sturdy instead of permanent press may end up shrinking and wrecking your clothes. Not starting the timer on my watch can lead me to forget about the load of laundry until bed time when I realize I still have a wet load in the washing machine. Thinking algorithmically about a task increases focus during execution, decreasing the frequency of mistakes.

The other point to realize here is that this type of approach really can be applied to virtually everything. Doing the laundry, cleaning your room, making a sandwich, grocery shopping, completing a series of errands involving driving around, studying for an exam, mowing the lawn, performing a workout, or my personal favorite, making coffee. It would not be difficult to add a dozen more things to this list.

Adopting this type of approach for most of the tasks you do takes some time. The ideal way to do this is to turn this type of algorithmic thinking into a habit. Eventually, you will find yourself completing more tasks, more quickly, with fewer errors and less time wasted.

Ultimately, I believe that your time is the most valuable thing you own. Saving 90 seconds because you made sure to bring your laundry detergent may not seem like a big deal. But, saving 90 seconds four times a day is three hours a month, which is one and a half days per year. This adds up to a couple of months in a lifetime. This, coupled with the fact that the things you do do are performed more accurately, makes such an algorithmic approach worthwhile. Before you know it, you will have lived a lifetime of slightly enhanced efficiency.