DSA by Mitul in C++, Python, and Java (Part 1): Introduction to Data Structure and Algorithms
Tags: dsa, ds, algorithms
Published: 2022-09-27 19:07:28

**What are Data Structure?**

Data structures are different ways to organize data.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ievb62bmmws1z425vfh3.png)

Also, if there are lots of people and you need to provide vaccine to everyone. If they are in a mess, you can not easily provide the vaccine. But if they are in a line , you can easily do the process or even search a particular person. 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/effo5ljw94ubeey3s3zf.png)


That's why data structure arrived to organize the data.


**What is algorithms?**
Algorithms are basically set of steps to accomplish a certain work.
This is what you do to get a cup of coffee from Starbucks:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m00cpiyjqim02qt9r4nt.png)

Let's know some real life example . 
1. Companies like Facebook, Google Hangout use compression algorithms to transmit live videos .

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dy2ihkkfxvq3mjl7pwe4.png)
2. Google maps use Dijkstra's algorithm.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/i3fhhcs0d85vxax592rp.png)

3. Optimization and scheduling algorithm is used by NASA at international space station.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/i62ysjpk96rfdvhj9571.png)


2 things make an algorithm important. 1) Correctness 2) Efficiency


**Why DSA is so important?**
Lets take an example of Google maps and here it takes your destination and current location, right?
So, it follows 3 steps. 1) Input 2) process 3) Output

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ymj2h2v40n7g2hgnzgjq.png)

In the process step, it uses DSA. Here they use Graph algorithms and Dijkstra's algorithm to find the shortest path very efficiently.

The interviewer still wants DSA skills because there are computers with high memory but if a developer does not know how to handle memory , the program may create memory leak. 

Also, if  a person is good at DSA, an interviewer expects that the person can learn any language easily.


**Types of Data Structures**
Firstly data is divided into primitive (By default data structures ) . For example, Integer, Float etc.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/f8t3jczk03awhsr2bjlg.png)


Secondly data is divided into Non Primitive/User created . For example : Stack,Tree


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m9fae07cyoz1aizc5wi0.png)

Non Primitive includes Linear & Non Linear DSA. Linear means the data is organized in a linear way but Non linear means , the data is not organized in a linear way.



**Types of Algorithms**
Generally there are algorithms like these:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xvx4qmmb7q0lj4yi1yw1.png)

1.Simple recursive algorithms general recursive codes.

2. Divide and conquer algorithms:
Divide the problem into smaller sub problems of the same type, and solve these sub problems recursively
Combine the solutions to the sub problems into a solution to the original problem
example: Quick sort, Merge sort
3.  Dynamic programming algorithms: They work based on memorization to find the best solution

4.Greedy algorithms:
Here we take the best we can without worrying about future consequences.We hope that by choosing a local optimum solution at each step, we will end up at a global optimum solution


5.Brute force algorithms:It simply tries all possibilities until a satisfactory solution is found
6. Randomized algorithms:
Use a random number at least once during the computation to make a decision


So, that was it for the Introduction to DSA . Let's enjoy the other blogs.

<img src="https://media0.giphy.com/media/Nfs5y1kzJKfu/giphy.gif?cid=ecf05e472d3w835ptrri5m1p6ifnwl9mi7ope9pifvhpcxf6&rid=giphy.gif&ct=g">