Wednesday, March 19, 2014

ALGORITHM

Algorithms are one of the most basic tools that are used to develop the problem solving
logic. An algorithm is defined as a sequence of clear instructions that, when provided with a set
of input values produces an output and then terminates. To be an algorithm, the steps must be
unambiguous and after a finite number of steps, the solution of the problem is achieved.
However, algorithms can have steps that repeat (iterate0 or require decisions (logic and
comparison) until the task is completed.
Different algorithms may accomplish the same task, with a different set of instructions, in
more or less the same time, space, and efforts. For example, two different recipes for preparing
tea, one ‘add the sugar’ while ‘boiling the water’ and the other ‘after boiling the water’ produce the
same result. However, performing an algorithm correctly does not guarantee a solution, if the
algorithm is flawed or not appropriate to the context. For example, preparing the tea algorithm will
fail if there are no tea leaves present; even if all the motions of preparing the tea are performed as if
the tea leaves were there. We use algorithms in our daily life. For example, to determine the
largest number out of three numbers A, B, and C, the following algorithm may be used.
Step 1 : Start
Step 2 : Read three numbers say A,B,C
Step 3 : Find the larger number between A and B and store it in
MAX_AB.
Step 4 : Find the larger number between MAX_AB and C and store it
in MAX.
Step 5 : Display MAX
Step 6 : Stop

The above-mentioned algorithm terminates after six steps. This explains the feature of finiteness. Once the solution is properly designed, the only job left is to code that logic into a Algorithm Properties.
Properties of Algorithm are:
  • There must be no ambiguity in any instruction.
  • There should not be an uncertainty about which instruction is to be executed next.
  • The description of the algorithm must be finite. An algorithm cannot be open-ended.
  • The execution of the algorithm should conclude after a finite number of steps.
  • The algorithm must be general enough to deal with any contingency.

No comments:

Post a Comment