What is an algorithm

What is an algorithm?

The set of rules or processes to solve the problem step by step is known as an algorithm.

introduction of the algorithm:

Why need to learn algorithm?

Firstly, the algorithm introduces by the musa-al-Khwarizmi 1300 years ago.He is also called the founder of computer science. Because the computer works on the algorithm. In the computer, million of the algorithms are running.

For example, you want to know about the address of your friend. your friend tell you to address like that take right from your house, skip three streets, turn left and 3rd house.

This address is much easier to follow these steps to reach the destination. In the same way, algo work follows the steps to reach your destination. In the computer solving problem, the algorithm works to reach the desired output.

Take another example of sorting, the sorting is used in the computer on a large scale. Fetching the data from the server, email list, folders, google use sorting very much. Google always tries to find an efficient algorithm of the sorting.

There are a lot of algos of the sorting available like, selection sort, graph search, and merge sort, etc.

Example of the algorithm:

Take the average of the three number

Psuedo code:

1-declare  variables num1,num2,num3,sum,and average.

2-take input three number  from the user in num1,num2,num3

3-add the num1,num2,num3 variables and assign to the sum

4-divide the sum by the three and assign to the average.

5-display the average.

The step by step process makes the easy to achieve the desired output. In this way algorithm help in computer science.No doubt, without algorithm computer science is useless.

Find the factorial of the number 5

1-declare and define the variables num=5,factorial=1.
2-use for loop initializes by num and terminate condition >1.
3-In the body of the loop, factorial multiple by the counter of the loop and save the value in the factorial variable again.
4-After the loop terminates,factorial of the 5 is saved in the factorial variable.

Difference between good and bad algorithm:

Good algorithm 


1-input or output precisely defined

2-take less runtime

3-each step performed in the  finite time

4-The each step should not be repeated infinitely.

5-steps in the proper manner

  Bad algorithm

1-no proper defined input or output

2-large runtime

3-step performed with large time

4-steps is not the proper manner

5-not generic


A good also help in the performance speed of the processer of the computer. If the good algorithm work on the old processor then works the same as on the advance processor.

Please write the comment,if you find anything incorrect and any problem in the above topic or you want to share more information about the above topic.


Hire a programmer

Popular posts from this blog

Python program to print Hello wolrd

input by cin in c++

pre increment or post increment in c++