• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Algorithm vs. computer program

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is the difference between an algorithm and a computer program?
 
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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).
 
lowercase baba
Posts: 13089
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
sometimes an example might help.

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.
 
Sasha Hernandez
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Would a computer program be a kind of an algorithm since programs implement algorithms?
 
Ranch Hand
Posts: 180
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

Hope this clears your doubt.
 
Ranch Hand
Posts: 1272
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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).

 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic