Algorithm is a step-by-step procedure, which defines a set of instructions to be executed in a certain order to get the desired output. Algorithms are generally created independent of underlying languages, i.e. an algorithm can be implemented in more than one programming language.
Characteristics of An Algorithm:
There are five important characteristics of an algorithm that should be considered while designing any algorithm for any problem.
- Fineness: An algorithm should terminate infinite number of steps and each step must finish in finite amount of time.
- Definiteness (No Ambiguity): Each step of algorithm should be clearly and precisely define and there should not be any ambiguity. Example: A program fragment is given below:
x ← 1.
toss a coin, if the result is head then x← 3 else x ← 4.
In the above program, all the steps would be carried out effectively but there is no definiteness since there are two possible values of x i.e., 1 and 3/4 - Inputs: An algorithm must have zero or more but must be finite number of inputs. Example of zero input algorithm. Print the ASCII code of each of the letter in the alphabet of the computer system.
- Output: An algorithm must have at-least one desirable outcome, i.e., output.
- Effectiveness: An algorithm should be effective. Effective means that each step should be referred as principle and should be executing in finite time.
0 Comments