beanz Magazine

What is an Algorithm?

ljphillips34 on Flickr

Algorithms control our lives online and offline. Here are some examples to show what is an algorithm and how they work.

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

Also In The April 2014 Issue

How to Make a Twitter Bot

There are a ton of ways to make a Twitter bot. Here are a number of resources, ideas, and clues to follow up.

What is an Algorithm?

Algorithms control our lives online and offline. Here are some examples to show what is an algorithm and how they work.

How to Build Example Bot

I have updated the installation instructions for this Github project to make it even easier to install and play with.

Bot Makers

A collection of bot makers and professor types attend an online bot convention to talk about Twitter bots and more.

File Extensions

You can tell a bit about the software used to create the web page you're reading by looking at the URL in your web browser.

Traceroute

A computer command used to diagnose network problems also lets you see how data hops across the internet.

How to Build a Slightly Complicated Website

Some tips on how to find online publishing services and use them to create your website.

What is an API?

APIs can be a fun, easy to use, and easy to learn way to retrieve and mash up data online.

April 2014 News Wire

Interesting stories about computer science, software programming, and technology for the month of March 2014.

Objects

Many programming languages organize their code into objects, to model their applications and make their code more reusable.

April 2014 Learn More Links

Links from the bottom of all the April 2014 articles, collected in one place for you to print, share, or bookmark.

At bottom, robotics is about us. It is the discipline of emulating our lives, of wondering how we work.