What is the difference between an algorithm and a computer program?
Below I've collected together the best explanations I could find...
Explanation 1:
Making a cake algorithm:
get ingredients.
combine ingredients
put in pan
bake in oven
let cool
Making a cake recipe/program.
you will need 2cups flour, 2 cups sugar, 1tsp baking soda...
sift together dry ingredients into a large bowl.
fold in liquid ingredients, and stir until moist.
beat another 2 minutes on high.
pour into 2 10" round cake pans
bake in 375 degree oven for 25-30 minutes
take out of pan and let cool on cooling racks
..etc.
notice that the algorithm is VERY general, but gives you the idea of what is involved, what steps are required (and sometimes what NOT to do). it's enough to let you know if you can do it, what it might require.
the recipie/program is for making a specific kind of cake, and will actually produce one. it's VERY detailed, with no room for playing around (ok, so baking isn't the perfect analogy).
Every cake recipie will "implement" the cake algorithm, but slightly differently, giving slightly different results.
A computer algorithm is nothing but a guideline to solve a particular problem. This guideline can be shown by graphs or steps or whatever easily understandable.
a program is a detailed set of instructions for a computer to carry out while an algorithm is a detailed sequence of steps for carrying out some process
Algorithm: A set of instructions or procedures for solving a problem
(found here)
Program: The set of instructions within a computer which enables it to perform the various tasks required
(found here)
In addition to above, Algorithm is a set of finite number of statements which is designed to end in a finite amount of time where as in a program the ending is not guaranteed. It might run infinitely(ex: infinite while loop).
Teaching Algorithm to a five year old:
The first lesson, riding her bike, is going to take longer than this weekend but she gave it a good crack.
The second, learning about Algorithms was much easier and she got it straight away. I was astonished at how easily she picked up the word and handled it. She can now tell anyone who asks (pretty much me) that Algorithm means ‘instructions to do something’. She even offered her own example Algorithm as I was stuttering around for a suitable one.
Children continue to prove they are mentally as quick if not quicker than I am most of the time. She asked if an algorithm could “paint a square” so we wrote a square algorithm, verbally, during a car journey: draw across, draw down, draw back across then draw up. Granted, it needs some additional accuracy but considering all that was learned and practised in the space of five minutes is incredible.
Her ability to grasp the word, understand it and furnish the word with her own examples gives great credibility to the idea that children at this age can learn to solve problems programmatically. In fact, the hardest part was pronouncing it!
The reason I wanted to start with the word Algorithm was simple. For me, Algorithm is the most powerful word in our Computer Science lexicon. It is the single most important foundation upon which the discipline sits and can build on. That single word can solve millions of problems larger than the mind can often comprehend. It’s a mathematically beautiful concept. The fact a Turing complete machine can run all algorithms is poetry.
Algorithm sounds a bit lofty, a classical sounding word that appears much more complicated that it is. It’s not. Like most mathematics, it’s a simple, economic and elegant idea.
For me it’s the heart of computer science and the part to focus on with children because once they grasp it, everything else is easy.
Below I've collected together the best explanations I could find...
Explanation 1:
Making a cake algorithm:
get ingredients.
combine ingredients
put in pan
bake in oven
let cool
Making a cake recipe/program.
you will need 2cups flour, 2 cups sugar, 1tsp baking soda...
sift together dry ingredients into a large bowl.
fold in liquid ingredients, and stir until moist.
beat another 2 minutes on high.
pour into 2 10" round cake pans
bake in 375 degree oven for 25-30 minutes
take out of pan and let cool on cooling racks
..etc.
notice that the algorithm is VERY general, but gives you the idea of what is involved, what steps are required (and sometimes what NOT to do). it's enough to let you know if you can do it, what it might require.
the recipie/program is for making a specific kind of cake, and will actually produce one. it's VERY detailed, with no room for playing around (ok, so baking isn't the perfect analogy).
Every cake recipie will "implement" the cake algorithm, but slightly differently, giving slightly different results.
A computer algorithm is nothing but a guideline to solve a particular problem. This guideline can be shown by graphs or steps or whatever easily understandable.
a program is a detailed set of instructions for a computer to carry out while an algorithm is a detailed sequence of steps for carrying out some process
Algorithm: A set of instructions or procedures for solving a problem
(found here)
Program: The set of instructions within a computer which enables it to perform the various tasks required
(found here)
In addition to above, Algorithm is a set of finite number of statements which is designed to end in a finite amount of time where as in a program the ending is not guaranteed. It might run infinitely(ex: infinite while loop).
Teaching Algorithm to a five year old:
The first lesson, riding her bike, is going to take longer than this weekend but she gave it a good crack.
The second, learning about Algorithms was much easier and she got it straight away. I was astonished at how easily she picked up the word and handled it. She can now tell anyone who asks (pretty much me) that Algorithm means ‘instructions to do something’. She even offered her own example Algorithm as I was stuttering around for a suitable one.
Children continue to prove they are mentally as quick if not quicker than I am most of the time. She asked if an algorithm could “paint a square” so we wrote a square algorithm, verbally, during a car journey: draw across, draw down, draw back across then draw up. Granted, it needs some additional accuracy but considering all that was learned and practised in the space of five minutes is incredible.
Her ability to grasp the word, understand it and furnish the word with her own examples gives great credibility to the idea that children at this age can learn to solve problems programmatically. In fact, the hardest part was pronouncing it!
The reason I wanted to start with the word Algorithm was simple. For me, Algorithm is the most powerful word in our Computer Science lexicon. It is the single most important foundation upon which the discipline sits and can build on. That single word can solve millions of problems larger than the mind can often comprehend. It’s a mathematically beautiful concept. The fact a Turing complete machine can run all algorithms is poetry.
Algorithm sounds a bit lofty, a classical sounding word that appears much more complicated that it is. It’s not. Like most mathematics, it’s a simple, economic and elegant idea.
For me it’s the heart of computer science and the part to focus on with children because once they grasp it, everything else is easy.