A finite sequence of steps required to get the desired output is called an algorithm. Algorithm has a definite beginning and a definite end , and consists of a finite number of steps .
- Algorithm is required by a programmer to clearly visualize the instructions it requires to code in order to develop a software.
- These also help him to identify the proper inputs and correct outputs.
The purpose of using an algorithm is to
increase the reliability, accuracy and efficiency of obtaining solutions.
Example: Algorithm to find largest of two numbers
Characteristics of a good algorithm
- Precision — the steps are precisely stated or defined.
- Uniqueness — results of each step are uniquely defined and only depend on the input and the result of the preceding steps.
- Finiteness — the algorithm always stops after a finite number of steps.
- Input — the algorithm receives some input.
- Output — the algorithm produces some output.
While writing an algorithm, it is required to clearly identify the following:
- The input to be taken from the user
- Processing or computation to be performed to get the desired result
- The output desired by the user