Home »
Writing or Expressing Algorithm
» Writing or Expressing Algorithm
Writing or Expressing Algorithm
8. Writing or Expressing Algorithm
Pseudocode or structured English is suitable for expressing an algorithm.
Here, unlike natural languages, each statement has an unambiguous
meaning. Generally algorithm is expressed in any high level language
8.1 Analysis of Algorithm
Whenever you design an algorithm you must analyse it. You have to
determine the cost of algorithm. If the cost is less than the exisiting
algorithm, this algorithm will be implementable. Generally the cost of
multiplication, addition and data transfer is calculated. If the cost of a
new algorithm is of lower order than previous one then we are assured
that the algorithm will give better results. Let us begin to implement the
algorithm in a program.
Example: There are three numbers. You have to find their median. Write
the algorithm in structured English.
Consider a, b, c are numbers.
if b a c then
median a
else if a b c then
median b
else median c
endif.
No comments:
Post a Comment