# Why Data Structures and Algorithms Are Important to Learn?

**Array, Linked List, Stack, Queues, Searching, Sorting, Tree, Graph…**

Do you have questions that why should I study all the above-complicated stuff if it has absolutely no use in real life?? Why do companies ask questions related to data structures and algorithms if it’s not useful in a daily job??

A lot of beginners and experienced programmers avoid learning Data Structures and Algorithms because it’s complicated and they think that there is no use of all the above stuff in real life. So before we discuss the topic we are going to throw a simple problem at you and you need to find the solution for that.

If you need to search your roll number in 20000 pages of PDF document (roll numbers are arranged in increasing order) how would you do that?

- If you will try to search it randomly or in a sequential manner it will take too much time. You might get frustrated after some time.
- You can try another solution which is given below…
- Go to page no. 10000
- If your roll no. is not there, but all other roll no. in that page are lesser than your than
- Go to page no. 15000
- Still if your roll no. is not there. but this time all other roll no. is greater than your.
- Go to page no. 12500

Continue the same process and within 30-40 seconds you will find your roll number. * Congratulations… you just have used *the

**Binary Search algorithm**

**unintentionally..**This was just a simple example and you might have understood a little bit that why learning data structure and algorithms is important in real life. There are plenty of examples you can find in your daily life. So if you think that this skill is only important to crack the interviews of product-based companies then you are totally wrong.

From the above example, we can straightforward give two reasons to Learn Data Structure and Algorithms…

- If you want to crack the interviews and get into the product based companies
- If you love to solve real-world complex problems.

### To Crack the Interviews of the Top Product Based Companies

* Do you know that under the hood all your SQL and Linux commands are algorithms and data structures?* You might not realize this, but that’s how the software works.

Data structures and algorithms play a major role in implementing software and in the hiring process as well. A lot of students and professionals have this question that why these companies’ interviews are focused on DSA instead of language/frameworks/tools specific questions? Let us explain why it happens…

When you ask someone to make a decision for something the good one will be able to tell you “*I choose to do X because it’s better than A, B in these ways. I could have gone with C, but I felt this was a better choice because of this*“. In our daily life, we always go with that person who can complete the task in a short amount of time with efficiency and using fewer resources. The same things happen with these companies. The problem faced by these companies is much harder and on a much larger scale. Software developers also have to make the right decisions when it comes to solving the problems of these companies.

Knowledge of data structures like Hash Tables, Trees, Trees, Graphs, and various algorithms goes a long way in solving these problems efficiently and the interviewers are more interested in seeing how candidates use these tools to solve a problem. Just like a car mechanic needs the right tool to fix a car and make it run properly, a programmer needs the right tool (algorithm and data structure) to make the software run properly. So the interviewer wants to * find a candidate who can apply the right set of tools to solve the given problem. *. If you know the characteristics of one data structure in contrast to another you will be able to make the right decision in choosing the right data structure to solve a problem.

* Engineers working in Google, Microsoft, Facebook, Amazon-like such companies are different than others and paid higher as compared to other companies…but why?* In these companies coding is just the implementation and roughly takes 20-30% of the time allotted to a project. Most of the time goes into designing things with the best and optimum algorithms to save on the company’s resources (servers, computation power, etc). This is the main reason why interviews in these companies are focused on algorithms as they want people who can think out of the box to design algorithms that can save the company thousands of dollars. Youtube, Facebook, Twitter, Instagram, GoogleMaps all these sites have the highest number of users in the world. To handle more users on these sites it requires more optimation to be done and that’s the reason product-based companies only hire candidates who can optimize their software as per user demand.

**Example:** Suppose you are working in a Facebook company. You come up with an optimal solution of a problem (like sorting a list of users from India) with time complexity of O(nLogn) instead of O(n^2) and assume that n for the problem here for the company in real life scenario is 100 million (very fair assumption considering the number of users registered on Facebook exceeds 1 billion). nLogn would be 800 million, while n^2 would be 10^7 billion. In cost terms, you can see that the efficiency has been improved more than 10^7 times, which could be a huge saving in terms of server cost and time.

Now you might have got that companies want to hire a smart developer who can make the right decision and save company resources, time, and money. So before you give the solution to use a Hash table instead of List to solve a specific problem think about the big scale and all the case scenarios carefully. It can generate revenue for the company or the company can lose a huge amount of money.

### To Solve Some Real-World Complex Problems

Have you ever been scolded by your parents when you were unable to find your book or clothes in your messed-up room? Definitely yes…your parents are right when they give the advice to keep everything in the right place so the next time you can get your stuff easily. Here you need to arrange and keep everything (data) in such a structure that whenever you need to search for something you get that easily and as soon as possible. This example gives a clear idea that how important it is to arrange or structure the data in real life.

Now take the example of a library. If you need to find a book on Set Theory from a library, you will go to the maths section first, then the Set Theory section. If these books are not organized in this manner and just distributed randomly then it will be frustrating to find a specific book. So data structures refer to the way we organize information on our computer. Computer scientists process and look for the best way we can organize the data we have, so it can be better processed based on input provided.

A lot of newbie programmers have this question that where we use all the stuff of data structure and algorithm in our daily life and how it’s useful in solving the real-world complex problem. We need to mention that whether you are interested in getting into the top tech giant companies or not DSA still helps a lot in your day-to-day life. Don’t you believe us…Let’s consider some examples…

- Facebook (Yes… we are talking about your favorite application). Can you just imagine that your friends on Facebook, friends of friends, mutual friends they all can be represented easily by Graph? Relax….sit for a couple of moments and think again…you can apply a graph to represent friends’ connections on Facebook.
- If you need to keep a deck of cards and arrange it properly how would you do that? You will throw it randomly or you will arrange the cards one over another and from a proper deck. You can use Stack here to make a proper arrangement of cards one over another.
- If you need to search a word in the dictionary, what would be your approach? Do you go page by page or do you open some page and if the word is not found you open a page prior to/later to one opened depending upon the order of words to the current page (Binary Search).

The first two were a good example of choosing the right data structure for a real-world problem and the third one is a good example of choosing the right algorithm to solve a specific problem in less amount of time.

All the above examples give you a clear understanding that how the organization of data is really important in our day-to-day life. Arranging data in a specific structure is really helpful in saving a lot of time and it becomes easier to manipulate or use them. The same goes for the algorithm…we all want to save our time, energy and resources. We all want to choose the best approach to solve the problems in our daily life. A lot of problems exist in the world that can take hours or days to be solved with the native solution, it also may take years ! can you imagine! watch this: Importance of Data Structure and Algorithms

We are surrounded by a lot of real-world complex problems for which no one has the solution. Observe the problems in-depth and you can help this world by giving the solution which no one has given before.

Data structure and algorithms help in understanding the nature of the problem at a deeper level and thereby a better understanding of the world.

If you want to know more about Why Data Structures and Algorithms then you must watch this video of **Mr. Sandeep Jain** (CEO & Founder, GeeksforGeeks).