Loading, please wait...

A to Z Full Forms and Acronyms

Classification of algorithms

Aug 28, 2019 algorithm , 2156 Views
in this article you will learn about algorithm

Algorithm:- Algorithm is a very popular technique used to obtain a solution for a given problem. The algorithm is defined as ‘the finite set of steps. Which provide a chain of actions for solving a definite nature of problem’.

The classification of the algorithm is based on repetitive steps and on control transfer from one statement to another. On the basis of repetitive steps, an algorithm can further be classified into two types.

i) Direct Algorithm:- In this type of algorithm, the number of iterations is known in advance. For example, for displaying numerical numbers from 1 to 10, the loop variable should be initialized from 1 to 10. the statement would be as follows:

for (j=1; j<=10;j++)

In the above statement, it is predicted that the loop will iterate 10 times.

ii) Indirect Algorithm:- In this type of algorithm repetitively steps are executed. Exactly how many repetitions are to be made is unknown.

For example, the repetitive steps are as follow:

i) To find the first Armstrong numbers from 1 to n, where n is the fifth Armstrong number.

ii) To find the first three palindrome numbers.

Based on the control transfer, the algorithms are categorized in the following three types.

i) Deterministic:- Deterministic algorithm is based on either to follow a ‘yes’ path or ‘no’ path based on the condition. In this type of algorithm when control comes across a decision logic, two paths ‘yes’ or ’no’ are shown. Program control follows one of the routes depending upon the condition.

Example:

Testing whether a number is even or odd. Testing whether a number is positive or negative.

ii) Non-deterministic:- In this type of algorithm to reach the solution, we have one of the multiple paths.

Example:

To find a day of the week.

iii) Random algorithm:- After executing a few steps, the control of the program transfer to another step randomly, which is known as a random algorithm.

Example:

A random search

A to Z Full Forms and Acronyms