Naked Science Forum

General Science => General Science => Topic started by: Karen W. on 05/03/2009 03:37:18

Title: What is an algorithm and how does it work?
Post by: Karen W. 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...?
Title: What is an algorithm and how does it work?
Post by: RD 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 ...

 [ Invalid Attachment ]
 
http://www.thenakedscientists.com/forum/index.php?topic=19379
Title: What is an algorithm and how does it work?
Post by: techmind 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).