Algorithm:
An algorithm is a finite, ordered step by step procedure to solve a particular
problem.
An algorithm consists a set of instructions to solve the problems.
It is a sequence of steps that transform the input into a valuable or required output.
Properties of an algorithm:
Algorithm must have the following characteristics.
Input:-An algorithm should have zero or one or more inputs.
Output:-An algorithm must have at least one output.
Finiteness: An algorithm must terminate after finite number of steps.
Definiteness: Each step of the algorithm must be clearly defined (unambiguous.).
Effectiveness: Each step must be simple, clear and easy to carry out with pen and
Paper.
Example:
Write an Algorithm to find the sum of two numbers.
Step1: Start
Step2: Read two numbers a,b
Step3: s= a+b
Step4: Display s
Step5: Stop
In the above algorithm
Input – a,b
Output – s
Finiteness – Completed in finite amount of time ( 5 steps)
Definiteness – each step is clearly defined (unambiguous.)
Effectiveness: Each step must be simple, clear and easy to carry out with pen
and paper.