Algorithms, the rhythm of machines

Algorithms, the rhythm of machines

“Less than a minute !!!”, I whispered with surprise when the professor explained how a few lines of code could solve a problem in less than a minute which would take more than 10 years otherwise. That was the experience of an online course I took a few months back.

While we shop online, browse the web, scroll through Facebook, make digital payments, work with our laptop, book a cab, travel the world, even as we save lives, they back us in our every action. It's as if our modern world is held together by them. They are getting better and better every day and we won't even notice. These are step by step instructions called algorithms. Yes, that course was on Algorithms. An algorithm, in easy words, is a set of instructions we follow to solve a problem or perform a task. Making tea, for example, involves a set of tasks. You can’t make good tea by putting tea powder, sugar, ginger, water in a bowl, and turning on the gas all at once. You need to follow the steps, the recipe, the algorithm. The set of tasks you perform to reach college from home can be called an algorithm. The faster you reach college from home, the better your algorithm is.

It's after decades of research, algorithms are faster and more efficient than they have ever been. But you may ask where do we see algorithms? Well, you can't see them because they work behind the scenes. When you use Google search, you get about a million results in less than half a second. On top of that, the most relevant results are always on top. It's because page-ranking algorithms combined with searching algorithms do the magic. Remove the algorithm, and your search results will both take time and be unrelated. When two computers from two different parts of the world connect, routing algorithms do the magic of finding the shortest path for data packets between the computers. With the right knowledge of algorithms, one can cut short the time taken by computers to solve a problem from hours to seconds. Algorithms at their core make use of mathematical observations to solve problems.


You must have studied prime numbers in school. Yes, the uncanny ones that can be divided only by 1 and themselves. They showed no patterns and seemed useless. Well, this mysteriousness has led us to develop algorithms that keep our digital data secure. For developing encryption algorithms we need big prime numbers. Even for generating prime numbers quickly, algorithms already exist. The speed of an algorithm depends on how fewer instructions it takes to achieve the same results.

We use algorithms on data, but sometimes structuring or ordering the data helps the algorithm achieve its full potential. This ordering of data combined with algorithms has helped us make the quickest responding Databases today. This is the reason modern web applications respond to your queries instantly. Ordering data is one thing but reducing its size without loss of information requires another type of algorithms. When it comes to storing data, videos occupy the most space. Facebook, WhatsApp, Youtube, Twitch, or any video streaming application, contain videos with watch time from million to billion minutes. Videos with a total watch time of several years are uploaded on Youtube every hour. Space issues are solved by a class of algorithms called compression algorithms.

There's another class of algorithms called dynamic programming algorithms. Dynamic programming is a problem-solving technique where you store the result of your calculations so that you don't calculate things again. I'll give you a quick example, let's say you need an algorithm that gives the sum of all numbers between two numbers a and b, where a is a two-digit number and b is a four-digit number. For example, if a is 90 and b is 1051, you calculate the sum from 91 to 1050. If I query you 1000 times with different values of a and b each time, and you simply calculate the sum by going through each number from a to b, that's too slow. There's a better option, what if we pre-calculated the sum from 100 to 1000 and stored the sum somewhere? That way we only have to add the sum from a to 100 and 1001 to b, add the previously stored result to this and there you have your answer. We have cut short the number of calculations for every next query. That's what an OS in a computer does to load programs faster, browsers do to load webpages faster and servers do to respond to queries faster. That was just a small glimpse of how an algorithm does its magic. The example may seem easy but using dynamic programming in completely new problems is more complicated.

The tech giants, the conglomerates, use algorithms to extract data from users. When someone has access to what you like, what you buy, how you behave, that's a very powerful thing. Applications and products like Facebook, WhatsApp, Youtube, The Google search engine, Gmail, GSuite (Drive, Docs, Sheets, etc) all being free isn't a coincidence, they all use your data to sell you the future. And this gazillions of gigabytes data is useless without algorithms that process them. These algorithms are called machine learning algorithms, to get it working you need to feed it with the relevant data and it finds out patterns in that data that can be used to analyse, classify, and predict things. These algorithms are used to make traffic predictions, self-driving cars, video surveillance, disease prediction, weather prediction, probability sampling, data segregation, etc.

Algorithms are everywhere. Computer code is algorithmic. The games you play are a game of algorithms. Online-dating, all form of ads, book recommendations, course recommendations, product recommendations, GPS mapping, interactive gadgets, digital assistants, financial transactions, online trading, etc. Everything is a play of algorithms. Even cyber-attacks and breaking into cryptographically secured places are done using algorithms. Algorithms have reached a point where they are self-programming and self-evolving.

We can't imagine a world without algorithms but with great power of algorithms, comes great danger if misused.

Sudheer Tripathi