What is an Algorithm? | A Beginner’s Guide to Algorithm

What is Algorithm?

What is Algorithm?

An algorithm is a set of rules or instructions that are used to solve a problem. It’s a more controversial word in Mathematics and Computer Science world.

Let’s take an example,


Here I just picked up some random numbers. Just have a look at these numbers. Take your own time and find the biggest number from this list.


So you might identify that 9 is the bigger one from this list of numbers, correct? OK, now go back and just think slowly about what you did to find the biggest number from this list.


You started looking at this first number and then you have moved to the second number and you might compare the second number with the first one and your mind stores that 4 is the biggest number for now.


And then again your eyes have moved to the next number and compare this with the number which you already memories as a bigger one that is 4. Since the next number is less than 4 your mind keeps 4 as the biggest number.


Again for the next number you know still 4 is the biggest number.


And again the next number, it’s 9. So your mind automatically registers that nine as the bigger number now by comparing with 4. and you would more to do next number.


It’s not greater than 9. So you kept 9 is the bigger one.


And then the last number again number. So you declare 9 is the bigger number from this list. This is how you identified 9 as the bigger number from this list, Right?

Do you know what you did now? You have just used some procedure to identify a bigger number, Right?

This is what an algorithm is. An algorithm means a well-defined procedure to implement something. That may be a lot of ways to implement this specific problem but the algorithm is the efficient way to do that. Or simply we can say that an algorithm takes a value or set off value as input and produce the value or set off value as the output.

So an algorithm is a sequence of steps that transform the input into the output.

Example of an algorithm

To understand this more clear we’ll take an example.

Let us consider the problem of preparing an omelette. To prepare an omelette we have to follow some steps.

To prepare an omelette
1) Get the frying pan.

2) Get the oil.

	a. Do we have oil?

		i. If yes, put it in the pan.

		ii. If no, do we want to buy oil?

			1.If yes, then go out and buy.

			2.If no, we can terminate.

3)Turn on the stove, etc...

First, we how to get the frying pan and then the second step is we have to get the oil. Here, we have to check whether do we have oil or not.

If we have oil we have to put it in a frying pan. Otherwise, we have to decide do we need to buy oil or not.

If yes then we have to go and buy. Else we have to terminate the process.

Once we have the frying pan and we have oil then we have to turn on the stove and do the cooking.

That’s it right? Here, what we are doing we are providing a step by step procedure to make an omelette.

It’s an algorithm for preparing an omelette.


So, an algorithm is a set of step by step instructions working quietly behind the scenes. We can also view an algorithm as a tool for solving a well specific problem. Again I’m letting that algorithm means well-defined procedures for the implementation.

In real-time for the specific problem, we might have a lot of options to choose from the algorithms. It’s very important analysis the algorithm to choose the right one for our problem statement.

For example, if you want to go from city A to city B. There can be many ways to go. for example by flight by bus by train and also by bicycle. Depends on the availability and convenience. We have to choose the one which is suitable for us. Similarly in computer science, multiple algorithms are available for solving the same problem.

So for example, a sorting problem has many algorithms. Like insertion sort, selection sort, quick sort and many more. It’s our responsibility to choose the right one. Analysis of the algorithm helps us to determine which algorithm is most efficient in terms of time and space consumed.


Kalpesh Khairnar

Hello Everyone, I'm Kalpesh. Energetic and passionate college student with the ability to work with open-source technologies. I spend most of my time in programming, blogging and helping other programming geeks.

Leave a Reply

Your email address will not be published. Required fields are marked *