An algorithm is a set of rules or instructions that step by step defined to solve a problem or to reach an expected goal. It is not a complete code or program but It can be described using a pseudo-code or flow chart.
Characteristics of Algorithms
- Input – The algorithm requires input as a problem. It can have any number of inputs and that should very clear what kind of input that algorithm needs.
- Clear and Clean (Unambiguous) – The algorithm should be clear, clean, and well-defined and It should have only those steps that will lead to the goal.
- Output – The algorithm should have one or more well-defined outputs.
- Finiteness – The algorithm should have an end. It should not be looping infinitely.
- Feasible (Doable) (Able to be done) – An algorithm process should be able to be done.
- Language Independent – An algorithm should have a step-by-step direction that can be done in any programming language. It shouldn’t be only for a single programming language that can’t be done or used in any other programming language.
Why use an Algorithm
- Scalability – An algorithm is used to solve a problem easier for small to large problems.
- Performance – It is used for performance also which means it is used to solve a big problem faster.
How to Design an Algorithm
To design an Algorithm, your algorithm should have to follow the following rule:
- The problem should be solved by the algorithm
- The rules of the problem should be strictly followed by the algorithm
- The input should be taken into the algorithm
- The algorithm should give an output after the steps of the algorithm.