# In simple terms... what the heck is an algorithm...?

Although I’ve read some books, I know that any explanation given here would widen my understanding, since I don’t have a big math background…

I understand basic algebra and stuff, so I would like to know in its most basic terms what an algorithm is…

And what does it represent…?

If you must you can use some technical terminology but please explain it.

An algorithm is nothing more than a set of instructions for performing a task. The concept is straightforward; the devil is in the details.

Or were you thinking of a logarithm?

So theoretically what is a “task”?

Could I say 1+1 is an algorithm?

Could I also say that when I kick a ball, I am effectively performing an “algorithm”? To what does the word “task” pertain to?

No I was thinking of an algorithm… No confusions there…

Sure. the algorithm for kicking a ball might look something like this:

1. Look at the ball
2. Switch weight to left foot
3. Bring right foot back
4. Take aim at the ball
5. Fling right foot forward

The “task” can be anything: extracting roots, determining a number to be prime or not, tracking subatomic particles in a colision, or tying your shoes. A task can have more than one algortithm, and some may be more efficient than others.

A definition commonly given in computer science courses is as follows: An algorithm is a finite, ordered set of unambiguous, executable steps, defining a terminating process, that provides a solution to a problem.

Algorithm for finding the square root of a number N when the calculator you have does not do square roots:

1- Make A= N/2+1
2- Make B=N/A
3- Make A=(A+B)/2
4- IF A has not changed since last iteration END
ELSE GO TO 2

In other words repeat the loop a few times until you are as close as you want. You will be surprised to see how quick it converges.

a recipe (perhaps not totally correct, but simple)

Loosely speaking, a “task” is a statement of the form “Given input satisfying conditions A, produce ouput satisfying conditions B.”

No. You have, arguably, given a task, which, if spelled out more explicitly, might read something like “Given 1 and 1, produce the sum of 1 and 1.” However, you haven’t given an algorithm, because you haven’t provided any instructions for how to complete this task.

In this case, your task could be “Given a ball and a leg, produce the kicking of that ball by that leg.”

In a very formal sense, algorithms are easy to understand–an algorithm is a Turing machine, and a Turing machine is an algorithm. This precise sense is necessary for showing that some problems can’t be solved by an algorithm (technicalities suppressed here).

For the common definition, a list of unambiguous steps to be taken in solving a problem is what’s usually given.

Or, in the loosest terms, an algorith is just a method. It will specify where you start, where you are going to end, and what exact sequence of steps you will take to get from one to the other. This can be very simple - for example, a recipe, even for hot water, is an algorithm. They can also be very complex - for example, the sequence of steps to generate a session key for a secure online transaction and apply it to the data to be exchanged. So long as you have a defined starting point (it can be very general, so long as it’s well defined), a defined ending point, and a method to get from the start to the end, you have an algorithm.

Note that an algorithm doesn’t have to terminate in certain cases. The algorithms used deep inside an OS that maintain resources and such are intended to run forever. When they actually do halt, that’s a bad thing in this case.

Strictly speaking, those wouldn’t be algorithms, but processes, ftg.

The processes are implementations of the algorithms. I know, I write the research papers for the algorithms that others have turned into real code used in real systems. I was just being informal. But it raises a good point.

What’s the difference between a program and an algorithm? What I have told students over the years:

A program is what I tell a computer.

An algorithm is what I tell a human being.

Computers need all the details and every comma in the right place. You can skip over details with humans. Also with humans, the more they know, the more you can leave out. E.g., “Throw these values into a hash table…” might be adequate in some cases.