## What is the algorithm?

Students, To understand efficiency of algorithm. First of all you should know what exactly algorithm is. Algorithm is a step by step procedure to perform a particular task in problem solving. It is written is natural laguage means our native language so that we can easily understand it.

### What is efficiency of algorithm?

Basically, we check the efficiency of the algorithm to find out how much time it takes to perform a task. There can be more than one algorithm to perform our task so we need to find out which one is better depending upon available algorithm solutions.

So, efficiency of algorithm can be measured by these two steps:

#### Number of steps:

An algorithm is considered more efficient it takes less number of steps to reach the result. Obviously, The shorter it is, the more it is easy to understand.

#### Space used in computer memory:

An Algorithm using less space in memory is considered more efficient with respect to memory space

For example:

We have two algorithm one takes less memory and other has less number of steps.so which one is better??

In this case, there is a trade off situation means we will take algorithm according to our requirements.

Example # 2:

Let’s suppose we have two algorithms to solve a certain problem. One algorithm has N steps whereas the other algorithm has N2 steps. In this case, the first algorithm is considered more efficient than the second one.

Lets understand with another example.

Example # 3:

We need to compute the followng:

1+2+3+4+5+….+99

How can we find its answer?

At this point, you need to find best possible solution to solve this algorithm. Different possible solutions are as follows.

Solution no 1:

we need to start adding numbers from the beginning and keep adding till the end.

Solution no 2:

In this solution, we make pairs like (1+99), (2+98), (3+97), (4+96)… (49,51). Each pair is the sum of 100. So we will count the number of pairs and and multiply that count with 100 and we add 50 to the final result.

Number of pairs * 100 + 50

Solution no 3:

Another solution is to use formula like n(n+1)/2 . So you need to solve 99(99+1)/2

These example shows that we have different solutions for different problems. Now you will decide which one is befficient according to your requirements.