|
Guidelines for Preparing Algorithm What is an algorithm? To those who aren't math-inclined, algorithms can sound scary. But they don't have to be . Algorithms are part of life, Any systematic, step-by-step set of instructions for solving a problem is an algorithm. Examples would include the instructions for programming a VCR, a 1040 income tax form or a cake recipe. Every computer program is an algorithm that tells the computer how to do something. The term algorithm is after the name of a famous ancient Persian Mathematician called Alkharazmi. Within programmers community algorithm is used to design programs. There are many tools, however, available to prepare program design. The one that we will be using in our programming courses is called pseudocode. Pseudocode A pseudocode is a compromise between a formal programming language and a natural (or human) language. The purpose of using a pseudocode in developing a program design is to provide a means of expressing the design which exhibits a degree of structure, but which avoids the exactness required by formal programming languages. In a professional program development environment, especially those stressing group programming efforts (Which is virtually all such environments), pseudocode tend to become highly formalized themselves. These formalized pseudocode are often referred to as design or program specification language. In our programming classes, we will be using a more informal pseudocode for expressing program designs. Our Pseudocde will be a blend of C++/Java and English language. C++/Java will be used to impart structure to the decomposition of the program into functions and to illustrate the flow of control within and between these routines. English will be used to express simple actions (or steps) within a function, steps which would be unnecessarily cumbersome to express using C++/Java. The elements of the our pseudocode which will be drawn from C++/Java are listed below:
The intend in using C++/Java as the basis of our pseudocode is to produce designs, the English portion of which can be "filled in" to produce a C++/Java program. Thus, it is no coincidence that your designs will look like somewhat imprecise C++/Java programs. See Deitel & Deitel pages 70-75 for an example of the evolution of a program from pseudocode design to C++ implementation. Similarly see Lewis and Loftus pages 109-111 for example of the evolution of a program from pseudocode design to Java implementation. Algorithm layout
A Simple Example (This example does not have function) Problem
First Refinement
Second Refinement
|
|
|