[prog] pseudocode

Mary mary-linuxchix at puzzling.org
Thu Jul 28 16:22:50 EST 2005


On Thu, Jul 28, 2005, Wolf Rising wrote:
> I'm sure this is a lame duck question, but what is the difference
> between pseudocode and an algorithm or are they for the most part the
> same thing?

The algorithm is the actual procedure for taking input data and turning
it into a result, the pseudocode is a description of it. The difference
is much the same as between a procedure for taking a bunch of
ingrediants and turning them into a cake, and a description of that
procedure. We call the description a 'recipe', but you can have multiple
recipes describing the same procedure, and you can have a procedure
without ever writing down a recipe. Likewise, pseudocode is one way of
describing an algorithm. (Others include flowcharts and waving your
hands about in the air while talking.)

Psuedocode's advantages are meant to be that it's slightly more compact
and readable to write it out in code-like English than it is to write it
out in code; and yet it remains relatively unambiguous. It can be a good
way to explain a relatively small design to the person who has to
actually write the code.

Its disadvantages are that it's only somewhat more compact than code,
and that it's actually quite easy to write buggy pseudocode, given that
you can't run it and test it. Many times, you are better off writing the
code once you get to more than 20 lines or so of pseudocode.

I think a lot of software engineering techniques, which include
pseudocode, flowchats, specifications and entire management structures,
don't make an awful lot of sense until you've actually done some small
sized software projects (1000 - 10000 lines of code, say) and started to
discover for yourself how hard it can be to keep the entire system in
your head. You also probably need to work on projects of about that size
in order to have an elementary programming design sense, which certainly
helps you understand how to use software engineering tools.

-Mary


More information about the Programming mailing list