### Analysis of algorithms part 1

## Analysis Of Algorithm

### Quick Intro

After Equipping ourself with different tools like linked list, we have cleared our fundamentals required for implementing some of the algorithms we will be learning here. other requirements we will learn as we move ahead.

The term algorithms itself defines an answer , answer to a particular problem. the steps which should be taken for solving the problem and how should we take it. There may be good algorithms and bad ones, our purpose of learning analysis of algorithms is to differentiate between the two, in todays post we will see why is algorithm analysis is necessary , where it is used and how to analyse the algorithm.

First Question which comes to our mind is why should we learn algorithms? back to the first post of the blog... Currently we have very fast machines, there is no doubt about it but even after having a fast machine and a poor algorithm applied program , it can be slower than the program which we run on a well devised program in a slow machine.

When we talk about algorithms , we talk about thinking, solving problems, puzzle solving and algorithmic thinking. when we talk about solving questions, there are efficiency factors associated with it , to make our solution more efficient, ie in time and space complexity, we analyse algorithms. Analysis of algorithms is an important concept we have multiple ways of analysing an algorithm but we usually take average case, best case and worst case for the programs.

**Worst case:**

In asymptotic analysis, worst case is the sequence of maximum steps taken to reach the solution through our program. suppose we have a linear list of items, arranged in a linked list we learned about previously. [Mango],[Strawberry],[Grapes],[Apples],[Pineapple].

these are arranged in a link respectively. suppose we have to find Pineapple in the data set.

for finding pineapple, we will have to go through each element in the linked list, check each element with the element pineapple and at the last node we will find our required data. thats our worst case. so for an N item linked list , we will have worst case as N.

its very important factor in analysis of algorithm.

**Best case:**

In asymptotic analysis, Best case is the case by which we achieve the answer in a minimum amount of time and steps through our program. In the above example, finding Mango would be our best case as it will be found in first step itself.

**Average case:**

As the name suggest, we take average of time taken by combining all the possible steps, its exhaustive in nature. ie Average case takes the time consideration for reaching each node available to us and does average on it.

**Final Note:**

Analysis of algorithms basically is how well our algorithm stands , how well we have thought about the problem and how well does it performs theoretically . Analysis of algorithm is required for research in algorithm, and basic thinking of what would its worst case be in terms of N ? The most important point to remember in design and analysis of algorithms is to ask questions , How would we solve the given problem? are there other ways from which we can get the answer? What will its worst case be ? can I improve my current algorithm even by a bit? All these questions add up and become constant improvement to our logical thinking and practical performance in developing algorithms.

**Written By,**

**Sarvesh Bhatnagar.**