* Design Of Algorithm
The first step in the program development
is to devise and describe a precise plan of what you want the computer to do.
This plan, expressed as sequence of operation, is called in algorithm. An algorithm
is just an outline or idea behind a program. Something resembling C or Pascal
but with some statements in English rather than within the programming
language. It is expected that one could translate each pseudocode statement to
a small number of lines of actual code, easily and mechanically.
Ø
Definition
An algorithm is a finite set of steps defining the solution of a
particular problem. An algorithm is expressed in pseudocode – something resembling
C language or Pascal, but with some statements in English rather than within
the programming language. Developing an efficient algorithm requires lot of
practice and skill. It must be noted that an efficient algorithm is one which
is capable of giving the solution to the problem by using minimum resources of
system such as memory and processor’s time. Algorithm is a language
independent, Well structured and detailed. It will enable the programmer to
translate into a computer program using any high-level language.
* Features of algorithm
Ø
Proper
Understanding Of The Problem
For designing an efficient algorithm, the
expectations from the algorithm should be clearly defined so that the person
developing the algorithm can understand the expectations from it. This is
normally the outcome of the problem definition phase.
Ø
Use Of
Procedures / Functions To emphasize Modularity
To assist the development, implementation and readability of the program,
it is usually helpful to modularize (section) the program. Independent functions
perform specific and well defined task. In applying modularization, it is
important to watch that process is not taken so far to a point at which the implementation
become difficult to read because of fragmentation. The program then can be
implemented as calls to the various procedures that will be needed in the final
implementation.
Ø
Choice
of Variable Names
Proper variable names and constants names can make the program more
meaningful and easier to understand. This practice tends to make the program
more self documenting. A clear definition of all variable and constant at the start
of the procedure / algorithm can also be helpful. For example, it is better to
use variable day for the day of the weeks, instead of variable ‘a’ or something
else.
Ø
Documentation
Of The variable
Brief of information about the segment of the code can be included in the
program to facilitate debugging and providing information. A related part of
the documentation is the information that the programmer presents to the user
during the execution of the program. Since, the program is often to be used by
persons who are unfamiliar with the working and input requirements of the program,
proper documentation must be provided. That is, the program must specify what
responses are required from the user. Care should also be taken to avoid
ambiguities in this specification. Also the program should “catch” incorrect responses
to its requests and inform the user in an appropriate manner.
* Criteria
to Be Followed By An algorithm
-
Input : There should be zero or more values
which are to be supplied
-
Output: At least one result is to be produced.
-
Definiteness: Each step must be clear and
unambiguous.
-
Finiteness: If we trace the steps of an
algorithm, then for all cases, the algorithm must terminate after a finite
number of steps.
-
Effectiveness: Each step must be sufficiently
basic that a person using only paper and pencil can in principle carry it out.
In addition, not only each step is definite, it must also be feasible.
Example
1 – Let us try to develop an
algorithm to compute and display the sum of two numbers
1.
Start
2.
Read two numbers ‘a’ and ‘b’
3.
Calculate the sum of ‘a’ and ‘b’ and store it in
sum
4.
Display the value of sum
5.
Stop
Example 2 – Let us try
to develop an algorithm to compute and print the average of two numbers
1.
Start
2.
Set the sum of the data values and the count to
zero.
3.
As long as the data values exist, add the next
data value to the sum and add 1 to the count.
4.
Compute the average, divide the sum by the
count.
5.
Display the average.
6.
Stop
* Flowcharts
The next step after the algorithm development is the flowcharting. Flowcharts
are used in programming to diagram the path in which information is processed
through a computer to obtain the desired result. Flowchart is a graphical representation
of algorithm. It makes use of symbols which are connected among them to
indicate the flow of information and processing. It will show the general
outline of how to solve a problem or perform a task. It is prepared for better
understanding of the algorithm.
·
Basic Symbols Used In Flowchart Design

No comments:
Post a Comment