What is an algorithm and how does it work?

  • 2 Replies

0 Members and 1 Guest are viewing this topic.


Offline Karen W.

  • Moderator
  • Naked Science Forum GOD!
  • *****
  • 31662
  • "come fly with me"
    • View Profile
What is an algorithm and how does it work?
« on: 05/03/2009 03:37:18 »
I have always heard it used and I think it has to do with groups of numbers, but I really don't know what it is, or how it works.
I would like to know what it is how it works...what Kind of things can it be used for etc...?
« Last Edit: 05/03/2009 03:49:21 by Karen W. »

"Life is not measured by the number of Breaths we take, but by the moments that take our breath away."


Offline RD

  • Neilep Level Member
  • ******
  • 8185
    • View Profile
What is an algorithm and how does it work?
« Reply #1 on: 05/03/2009 04:09:56 »
An algorithm is a fancy name for a list of instructions given to a computer: a.k.a. a computer programme.

Here is a simple flow diagram ...

« Last Edit: 05/03/2009 04:13:19 by RD »


Offline techmind

  • Hero Member
  • *****
  • 934
  • Un-obfuscated
    • View Profile
    • techmind.org
What is an algorithm and how does it work?
« Reply #2 on: 05/03/2009 08:56:14 »
An algorithm is a fancy name for a method of doing something. It's often associated with mathematical or logical "recipies".
An algorithm is usually quite detailed (but doesn't necessarily have to be the case). It can be a bit like a computer program, but describes the principle of what you want to do and how to go about it without the formality and syntax of a real programming language.

A computer program is often a specific embodiment or implementation of an algorithm.

You can often express an algorithm as a flow chart, but it might be equally valid to express it as a series of numbered steps, with options to jump back or forward to other steps depending on conditions.

If you wanted to solve a maze by a "brute force" (ie unintelligent, but reliable) method you could use the rule of "always follow the left-hand wall" (as an aside this rule won't work for mazes with any bits of unconnected wall). This could be considered a very simple algorithm for getting out of a maze.

Here's an example of an algorithm for creating random dot stereograms (those 3D pictures):
1. Start with a "depth-map" - array of z-values for each (x,y) point on the screen.
2. Working left to right along each horizontal line, for each point on the depth-map identify the associated pair of screen points and `link' them - give each a reference to its other half.
3. Again working from left to right, assign a random colour to each unlinked point, and colour linked points according to the colour of their (already coloured) other half.

This is taken from my web page: http://www.techmind.org/stereo/stech.html and which might also give some idea of how a computer program relates to an algorithm (although it's moderately advanced).
« Last Edit: 05/03/2009 09:05:21 by techmind »
"It has been said that the primary function of schools is to impart enough facts to make children stop asking questions. Some, with whom the schools do not succeed, become scientists." - Schmidt-Nielsen "Memoirs of a curious scientist"