dark mode light mode Search Menu
Search

What is an Algorithm?

ljphillips34 on Flickr

Or here’s a fun question: can you pronounce the word?

Google says the word is pronounced Al-Ga-Rhythm. I’ve also heard it pronounced Al-Go-Rhythm.

However the word is pronounced, algorithms are a critical but often hidden feature of both technology and human existence. Algorithms are a set of clearly defined rules, often with branching because some rules generate yes or no answers or take other input.

For example, you follow an algorithm of sorts every time you get dressed. If you hate red stripes you set yourself a rule, “Do not wear red striped shirts, pants, or dresses.” As you get dressed any given day, you might come across a red-striped shirt in your closet and ask yourself, do I wear this today or not? If you answer yes, I’ll make an exception today, or you forget you don’t like red-striped clothes, then you follow more rules and ask more questions, for example, does this fit? Does it look good on me? Am I done getting ready for the day?

Computer and machine algorithms follow the same process, with possible branching, but in a more rigid way. You might decide not to hate your red-striped outfit for today, but computer programs rarely have flexibility when they run their rule set. Predicting then accounting for possible dead ends is a key design and programming skill for software engineers.

Here’s a simple example of an al-ga-rhythm:

  1. Wake up
  2. Get Dressed
  3. Go to School
  4. Attend Classes
  5. Eat Lunch
  6. Attend More Classes
  7. Go Home
  8. Study
  9. Eat Dinner
  10. Play Video Games (or Read or watch TV)
  11. Go to Sleep

And here’s an algorithm everyone uses when they log in to a software application:

  1. Enter your log in details
  2. Are log in details all present?
    1. If yes, go to next step
    2. If no, go to the first step and display an error message
  3. Compare log in details with database with user log in data
  4. Is there a match between these log in details and what is in the database
    1. If yes, go to next step
    2. If no, go to the first step and display an error message
  5. Log the person in
  6. Show the person the application home page

And, here is a more complicated algorithm in a diagram:

algorithm flowchart of Euclid problem from wikipedia
An Algorithm Written as a Flowchart

Finally, algorithms are what make Twitter bots work, as shown in the code in this issue of the magazine. The programmers might have a brilliant idea to mash up data in fun or thoughtful ways. However, they have to create rules to turn their idea into software.

Why Algorithms Matter

It appears algorithms are no big deal, correct? The question, “what is an algorithm?” seems fairly easy to answer. It’s a set of rules.

Think about this problem, however: you love books and go online to browse a bunch of online bookstores looking for a specific book. You can’t find exactly what you want so you buy something close. What if the algorithms used to find your book were flawed? What if the algorithm used to find your book was too narrow and excluded a few books you would have loved to know about? Maybe the algorithm showed you books about cute kittens because the store had too many and wanted to dump their inventory?

Or consider a more serious case. What if you and your co-workers are concerned about the chemicals you work with? How would you find out whether the chemicals are dangerous? And if your company had accidents with this chemical? It’s theoretically possible to suppress negative information with algorithms. Not likely, but possible.

Almost every website and software application you use has at least one algorithm and these algorithms limit or expand your options.

Even more interesting, the positive and negative potentials of algorithms are similar to what we experience in real life without computers. You might walk into a used bookshop, for example, and find exactly what you want, more than what you want, or find another book of equal interest. But the inventory in the real world also has limits. The bookstore owner might love to read the same books as you and buy those books. And think about the differences between and online bookstore that displays books you might like (what are the rules they use?) and talking with the owner of a small bookshop about what they recommend (what do they base their recommendations on?).

The internet, however, does dramatically expand our access to good and bad information. So in the real world, without computers, people who work with chemicals at a plant might have few options to identify any harmful impacts from those chemicals. But the internet has the potential to make the information easily available.

In other words, algorithms are like humans. They are good, bad, and indifferent. Often at the same time. It’s important to understand your online experiences are controlled by algorithms and to ask questions about how those algorithms limit and expand your options.

Learn More

Wikipedia

http://en.wikipedia.org/wiki/Algorithm
http://en.wikipedia.org/wiki/List_of_algorithms

Sorting Algorithms (Computer Science Unplugged)

http://csunplugged.org/sorting-algorithms

Core Algorithms Deployed (Stack Exchange)

http://cstheory.stackexchange.com/questions/19759/core-algorithms-deployed