BBC Home

Explore the BBC

Front Page

Life | The Universe | Everything | Advanced Search
 
Front PageReadTalkContributeHelp!FeedbackWho is Online

Click here to complete your registration.

 
3. Everything / Leisure & Lifestyle / House & Home / Maintenance and Decoration
3. Everything / Maths, Science & Technology / Computers / Computer Languages and Programming
3. Everything / Maths, Science & Technology / Mathematics

Algorithms

An algorithm is a logical series of actions for performing a task. In life there are algorithms all around us; recipes, stereo manual, wardrobe assembly instructions, et. In fact, a computer program is simply an algorithm for a computer. In general, an Algorithm presents itself to us as a set of instructions which can be executed in order to achieve some goal.

So, you can say that the algorithm for washing your hands is:

  1. Go to sink
  2. Turn on water
  3. Run hands under water
  4. Pick up soap
  5. Rub soap on hands
  6. Put down soap
  7. Put hands underneath water
  8. Rub hands against each other
  9. Turn off water

Algorithms can also be transferable, in other words the same set of actions can be performed on different things, for example the action required to plug in and turn on a TV are technically the same actions required to plug in and turn on any electrical device. Therefore you can make an algorithm transferable by specifying a variable rather than a specific thing. So to make the last algorithm transferable to the washing of any article rather than just hands you specify a variable like this:

  1. Go to sink
  2. Turn on water
  3. Run [article to be washed] under water
  4. Pick up soap
  5. Rub soap on [article to be washed]
  6. Put down soap
  7. Put [article to be washed] underneath water
  8. Rub [article to be washed]
  9. Turn off water

How Do You Construct an Algorithm?

When you want to create an algorithm for a task you are basically wanting to note down the logically ordered series of actions and conditions that define how to perform the task. So to help, an algorithm for creating algorithms has been created.

One - Clearly Define the Task

If you are going to create an algorithm you have to have a clear understanding of what it is you have to define. So the best thing to do in this first stage is to note down what items are affected by this task and what areas this task covers.

Two - Define What Actions are Involved in the Task

Go through the task in your head and note down every action you can think of that's associated with the task. Try to define as many as you can think of, but don't worry if you miss any as we can pick them up later. Also don't worry about the order, we sort that next.

Three - Define the Order of These Actions

Go through your list of actions and see which actions have to be done before each action you look at, then make a note of it.

Four - Turn This into the Algorithm

Now take the list and construct an ordered list starting with the first action and building based upon which actions have to be done first. It is important to note that the more clear, simple, and unambiguous the instructions are, the better the algorithm. And it is always important to remember your audience, and what they are likely to understand (be the audience human or a computer).

Five - Are the Actions Clear?

It is always good to ask 'What knowledge would I need to understand this?' and 'Does the audience have this knowledge?' This is because quite often when we write instructions, we write as if we were explaining to someone with the same basic knowledge and understanding of concepts as ourselves; this can cause us to write very bad algorithms.

Six - Run Through the Algorithm

Now create an example case and run through your ordered list. You are trying to find actions that have to happen but aren't defined, no matter how small.

Seven - Note Things Missed and Rewrite Algorithm

This is important; in most cases the first version of an algorithm will omit something which you feel is obvious, but which may not be obvious to the reader.

Eight - If Corrections Have Been Made, Return to Point Five

By correcting and checking until you can see no more corrections is a very useful way to write an algorithm. This is because it allows you to pick up any errors, to make sure it is sufficiently clear, and be sure that your final version works to the best of your knowledge. This is known as iterative development.

Where Did it Get its Name?

The name 'algorithm' comes from the translation of the 9th Century Persian mathematician al-Khwarizmi's name1. He was in fact the mathematician who brought the Hindu decimal system and use of zero into Arabic mathematics amongst other things.


1 Also, the word 'algebra' is derived from the Latin translation of the title of one of his books. The title included the word al-jabr which means transposition.

Discuss this Entry  People have been talking about this Guide Entry. Here are the most recent Conversations:

A few comments
(Last Posting: Apr 22, 2006)

Programming
(Last Posting: Mar 7, 2003)




Add your Opinion!

There are tens of thousands of h2g2 Guide Entries, written by our Researchers. If you want to be able to add your own opinions to the Guide, simply become a member as an h2g2 Researcher. Tell me More!

 
Entry Data
Entry ID: A842960 (Edited)

Written and Researched by:
Researcher PSG [Minister of Impossibility and Improbability] - Peace!
Dancer (put your advert here)

Edited by:
U284


Date: 16   December   2002


Text only
Like this page?
Send it to a friend


Referenced Guide Entries
Genetic Algorithms


Most of the content on this site is created by h2g2's Researchers, who are members of the public. The views expressed are theirs and unless specifically stated are not those of the BBC. The BBC is not responsible for the content of any external sites referenced. In the event that you consider anything on this page to be in breach of the site's House Rules, please click here to alert our Moderation Team. For any other comments, please start a Conversation below.
 


Front PageReadTalkContributeHelp!FeedbackWho is Online

Most of the content on h2g2 is created by h2g2's Researchers, who are members of the public. The views expressed are theirs and unless specifically stated are not those of the BBC. The BBC is not responsible for the content of any external sites referenced. In the event that you consider anything on this page to be in breach of the site's House Rules, please click here. For any other comments, please start a Conversation above.


About the BBC | Help | Terms of Use | Privacy & Cookies Policy