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) [ June 28, 2004: Message edited by: Ben Buchli ]

in other words a computer program is a specific implementation of an algorithm or set of algorithms designed to be used in conjunction with computer hardware (and possibly other programs) to solve a problem whereas an algorithm does not define the way it is to be implemented (though specific algorithms might by their nature suggest specific implementations).

Making a cake algorithm: get ingredients. combine ingredients put in pan bake in oven let cool frost.

making a cake recipie/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.

There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors

Sasha Hernandez
Greenhorn

Joined: Oct 14, 2003
Posts: 21

posted

0

Would a computer program be a kind of an algorithm since programs implement algorithms?

Dear Sahsa, As explained by Ben, computer algorithm is nothing but a guideline to solve a particular problem. This guideline can be shown by graps or steps or whatever easily understandable.

But a computer program is a code for sloving a problem but written in a language understandable by computer(c++/Java/etc).

We cant say a computer program is an algo because Science Community has defined cetarin convention is describing an algo.

I'm sorry to muddy the waters, but for years ALGOL was used more as a format for publishing algorithms than as a language for programming an actual computer.

I think that a computer program is a kind of algorithm.

Some algorithms are compilable/executable programs, some algorithms are written in a computer programming language but wouldn't run as written, some algorithms are written in pseudocode such as found in CLRS, and some algorithms are written as mathematical formulas and/or in natural language.

TopCoder www.topcoder.com devides their ranking system into categories, and Algorithims has it's own category. This just illistrates the point that you can be a wiz at solving problems using algorithims and not be an expert programmer.

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).