Tuesday, 13 October 2015

Necessity of Algorithms


Algorithms play a great role solving problems in faster and easier ways...

With the introduction, you might be wandering, why the hell you would study another subject and stuff your brain with knowledge...

Well, if I tell you that there are many things you do on a day to day basis, those you do by following an algorithm, then ?

Hmm, baking a cake is following an algorithm, I agree.
What about a more simple stuff like applying shampoo on your hair ?

HOW ???
Well, most of the shampoo container comes with the instruction to wash your hair, something like: wet hair, lather, rinse, repeat

Do you find the consequence and the problem with the algorithm ?
You are most likely to be running out of your shampoo and your time.

How ?
Well, as a human being, you can assume that, you have to repeat just once. So, this works fine for you. But computers have no brain to think or assume. Just take a look on this article.

Consequently, it fails for a computer and you are most likely to avoid this algorithm.

Ohh no, all my works are gone ?
Of course not, you can think better strategy and device a new algorithm.

Can you think an alternative ?
What about this one, wet hair, lather, rinse, repeat once ?

Perfect one.

Feeling happy to device the new algorithm ?

Well,  what did I do ? Can you call it an algorithm ?
Yes, it is a modified algorithm which considers a boundary to the steps to be followed. So, it is an algorithm.

Wow !!!
Yeah, exactly the same feeling I had when I first solved this problem in the days of my algorithm classes.

Seriously, when you think of anything, you get a better way to do it. Not only this simple Shampoo Algorithm, you everyday perform executions of lots of other algorithms as well. Only thing is that, you do not know that it was an algorithm. Again, if you think closely to subject, you can find better algorithms to solve a problem.

So, what are the criteria it should meet to be an algorithm ?
You simply has to find the answers, if you find all the answers as 'YES', it is an algorithm.
  • Is it unambiguous? 
  • Does it have defined inputs and outputs? 
  • Is it guaranteed to terminate? 
  • Does it produce the correct result? 

Now my question to you is, how am I going to be benefited by algorithms ?
Well, there are multiple reasons, you should know about algorithms. When you study about algorithms, your work is influenced by the knowledge you gain. So you will always try to find a better way to do your stuffs.
Let's discuss with some examples,
  • First of all, take the shampoo algorithm. If the wrapper editor would have thought about the problem himself, he was supposed to device the modified algorithm.
  • In many situations, you have to work with collections of data. You can decide which one to use, an Array, a List or a Queue depending on the requirement. Assuming you will be using a list, which one is better in that, a linked list or Hashed Linked List etc.
  • How you achieve a requirement with less number of operations or memory usage.
  • How to device an algorithm for a better unique key design.
And many more you can do with the knowledge of algorithms.


In fact, there are many real time applications that use algorithms to get the output in minimal steps and minimal resource use.
Below are some,
  1. How does Google find billions of search results that too most perfect according to your need ?
    Google use PageRank algorithm.
  2. How does Hangout/Skype sends/receives video over network so fast ?
    They use Compression algorithm.
  3. How does Facebook maintains so many user data and that too perfectly ?
    Facebook use News Feed Algorithm.
So, you see, whatever you think is very complex, there always remains a algorithm to help the stuff and team always to improve their algorithms to stick to the market.


Well, most of the times you will not find a direct impact of Algorithmic study in your coding. Because, almost all the popular language comes with built in API to deal with the stuffs like searching, hashing, sorting etc. But you will find yourself writing a better implementation.

Well, if time permits for you, take a look into this video





Prev   Next

Palash Kanti Kundu

No comments:

Post a Comment