What is an Algorithm?
Post date: Oct 21, 2013 5:51:23 AM
There are various definitions available for term Algorithm as:
- "A set of rules for solving a problem in a finite number of steps" - Dictionary
- "A set of steps that are followed in order to solve a mathematical problem or to complete a computer process" - Merriam-Webster
- "An Algorithm is any well defined computational procedure that takes some value, or set of values, as input and produces some value, or set of values as output"- refer to References
- "A process or set of rules to be followed in calculations or other problem-solving operations, especially by a computer." - Google
Any of the above mentioned definition will work, and even all definitions provides a similar summary i.e. a set of well defined steps to solve a defined problem corresponding to provided inputs.
Five characteristics of an Algorithm are:
- Input: Accept Zero or more inputs externally.
- Output: Must produce at least one output as result of procedure.
- Definiteness: Each instruction must be clear and unambiguous.
- Finiteness: If all the instructions are traced in algorithm, then for all cases the algorithm must terminate after a finite number of steps.
- Effectiveness: Every instruction must be very basic so that it can be carried out and must be feasible to perform on any machine.
One important point about algorithm, it is not a computer program. Instead it is a procedure written as pseudo code or English language type description, providing information about what calculations are to be performed and in which flow.
For Example : To add two numbers we can have an algorithm like:
English language Type
1. Ask user to enter two integer numbers.
2. Add both the integer numbers.
3. Print the final sum value of two numbers
Pseudo Code Type
Input: Two Integer Numbers as ONE, TWO
Output: sum of ONE & TWO as RESULT
ONE <- User input required
TWO <- User input required
RESULT <- ONE + TWO
In case you want to show it visually it can be represented as: