The word algorithm means “process or set of rules that are used in calculations or other problems”. An algorithm is a set of instructions for solving a problem or completing a task. Every device uses an algorithm to complete the task. An algorithm is like a recipe that is used for making delicious food. The quality of food depends on the recipe. If the recipe is very effective then the food will also be very delicious. An algorithm should be very effective in terms of time complexity and easy to understand because an algorithm will be effective if it is easy to understand and effective in use.
Characteristics of Algorithm:
- Clear and Unambiguous: Every step of the algorithm is very important to get the desired output. Every step of the algorithm should be clear and consisting only one meaning.
- Language independent: An algorithm should be language independent. It should not be written for one particular language.
- Feasible: The algorithm must be simple, generic, and user-friendly.
- Minimum Time Complexity and Space Complexity: Space complexity refers to the amount of space it takes in memory and time complexity is the amount of time requires to execute and get the result. Minimum time and space complexity give the best result. The time complexity of the algorithm is measured in the notation of big oh, omega and delta.
How to write an algorithm: There is not any particular sequence for writing algorithm. Algorithm does not support any particular programming language.
Algorithm for adding two numbers:
Step 1 − START
Step 2 − declare two integers a and b
Step 3 − define values of a & b
Step 4 − add values of a & b
Step 5 − store output of step 4 to c
Step 6 − print c
Step 7 − STOP