
Algorithms are really about solving problems.There could be many different ways to solve the same problem.So when you have so many solutions available , it's up to you to decide what is the best solution that suits your needs.
But how do you decide what's the best solution?Usually it's a matter of money - of resources.The cheaper something is - the better it is.(Like Chinese cell-phones :)
When you have a problem and there are many different computer programs that will give you the solution to your problem - you would want to pick the program that runs the fastest - the one that uses up the smallest amount of computer memory and is straight-forward to understand (in case you need to fix it or tweak something).
Consider this:
You have a list of numbers and you want to sort them in ascending order.There are lots of ways to do this.
Say you googled and found 4 different ways.Let's call them:
1)Bubble Sort
2)Insertion Sort
3)Selection Sort
4)Merge Sort
Now which one would you use?
Well, it depends doesn't it.It depends on stuff like
1)How many numbers you have to sort
2)Which of these ways is fastest
3)Whether you understand what's actually happening behind the scenes.(You want to make an informed decision,right?)
You may also have to think about how these different algorithms (I am going to stop calling them 'ways' now) behave when you have different amounts of numbers (or the 'size of the input')
Some algorithms may be super fast when they are dealing with say, 10 numbers.However,they could end up being really slow when you have an input of around 10000 numbers.
On the other hand, there could be some algorithms that are really complex and hard to implement and totally not worth the trouble for sorting just 10 numbers.However, if you need to sort ,say a million numbers - these may come in handy.
The process of figuring out the how an algorithm behaves in different situations is called "Analysis of Algorithms"





