# What is an Algorithm?

Have** **you ever heard the word Algorithm? I think many of you might have, whether it was online or maybe in some conversation about technology. It’s a word that gets thrown around a lot. But what exactly does this mean. Well, simply put Algorithm is nothing but a formula for solving a problem. You can take it as a step-by-step guide for solving a problem. For now, you can understand it as a black box that takes input and produces an output. Now, you might be thinking that a recipe does the same work. Is it an algorithm then? Well, yes! Algorithms resemble recipes. The recipe tells us how to accomplish a task by performing some steps. However, an algorithm is a technical term with a more specific meaning.

In computer programming terms, an algorithm is a set of well-defined instructions to solve a particular problem. It takes a set of inputs and produces the desired output.

For example, a search engine is an algorithm that takes a search query as an input and searches its database for items relevant to the search query. It then outputs the results. Ah, that’s a bit of jargon. Let's make it simple using an example.

Here’s an algorithm to add 3 numbers and print their average:

**START**- Declare 3 integer variables num1, num2, and num3.
- Take the three numbers, as inputs in variables num1, num2, and num3 respectively.
- Declare an integer variable avg to store the average of the 3 numbers.

Add the 3 numbers, divide by 3 and store the result in the variable avg.

Print the value of variable avg. **END**

## Algorithm Analysis

Algorithm analysis provides theoretical estimates for the resources (space and time) needed by any algorithm which solves a given computational problem. We can analyze the efficiency of an algorithm by using time and space complexity.

**Time complexity**: The amount of time taken by an algorithm to run as a function of the length of the input. Time is an important factor because nobody would like a google search that would take 2–3 hours to give back the results.**Space complexity:**The amount of space or memory taken by an algorithm to run as a function of the length of the input. As we know, computer memory is limited, so space is also an important factor in measuring algorithms' efficiency.

## Algorithms in our daily life

We knowingly or unknowingly use algorithms everywhere around us, from mobile phones in our hands to ATMs in the market. Here are some of the famous algorithms we use daily:

**Google PageRank Algorithm**- It is one of the most widely used algorithms in the world. When we do a Google search, this is one of the elements to decide the order in which the results will be displayed. This is the algorithm that Google uses to determine the*importance*of a website, based on how many websites are linked to that website. Curious to know more about how this works?? Let me explain this in a bit more detail.

The algorithm assigns each webpage a number, called a *PageRank* (or *PR*), on a scale from 1 to 10. Higher numbers correspond to higher importance, which means the higher that webpage will appear in search results. The PR is one of Google's main factors to sort the search results when you search for a website. Another important factor is *relevance*. For example, if I were to search for “soccer”, notice how there are no pictures of cars in the search results. This is because cars are not relevant to my search query, but soccer balls, soccer players, and soccer fields are relevant. In general, Google shows you the most relevant and highest PR websites first. Relevance is actually computed by a separate algorithm used by Google that aids to organize data. The higher a website’s PR is, keeping the relevance of the search in mind, the higher it will be in the search results (if it is relevant to your query).To compute PageRank, Google actually uses a very clever computer program that is based on mathematical concepts from a field called “linear algebra”.

2. **The Facebook Timeline algorithm -**This is another algorithm that influences our life much more than we might think. The set of algorithms that feed the Facebook Timeline determines the contents that will be displayed in the most visited space of the social network. Thus, based on a series of parameters (personal tastes, response to previous content, etc.), the algorithms decide which content the social network will show us and in which order it will do so.

They are plenty more algorithms like mobile banking algorithms, ATM algorithms, High-frequency trading algorithms, and the list goes on and on…

## Algorithms- The future of business success

Algorithms have allowed organizations to scale in ways that weren’t possible even five or 10 years ago. Don’t believe me? Let’s see stats! Google is an organization that has mastered data and algorithms. In 2002, their search algorithm earned them half a billion dollars a year. That’s already good money by any standard, but their investments into algorithms are really paying off now. The latest version of their search algorithm now makes a billion dollars in just one day. In other words, they’re now collecting the same amount of revenue in less than one percent of the time it used to take.

With the advancement in technology, two exciting fields emerged at the frontier of this new world: **Machine Learning** and **Deep Learning**. Some examples which are leveraging these fields are the Netflix Movie recommendation system, Facebook DeepFace project, Tesla self-driving cars, and many more. With the rapid development of technology, there is an explosion of data that can be mined, algorithms have become a critical future component of every successful business.

Whoa! That's a ton of knowledge but I hope you enjoyed reading this and now you can answer “What is an algorithm?”. If yes!, share it on Twitter.

Feel free to connect. I’m active on Twitter and LinkedIn.

Read my previous articles here.

Cheers!