What is an Algorithm? Explain characteristics of an algorithm with the help of an example.
Algorithm:
Technically, the set of instruction or description in a particular notation of the process is termed as algorithm. An algorithm is a finite step-by-step well defined instructions of the sequence of the activities that constitute a process of getting the desired outputs from the given inputs. The raw material needed at the time of beginning is referred to as input and the rusting entity is referred as output.
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.
Also Read | Must Read Books for Software Engineers – Better Developer
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 as: 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. Example of Not Effectiveness: Find exact value of e using the following formula:
Also Read | How To Develop World Class Behaviors Skills?
It is not effective since it requires summation of infinite terms. Therefore, it takes infinite time hence not effective.