What are Data Structure?
Data structures are different ways to organize data.
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.
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:
Let's know some real life example .
- Companies like Facebook, Google Hangout use compression algorithms to transmit live videos .
- Google maps use Dijkstra's algorithm.
- Optimization and scheduling algorithm is used by NASA at international space station.
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
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.
Secondly data is divided into Non Primitive/User created . For example : Stack,Tree
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:
1.Simple recursive algorithms general recursive codes.
- 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
- 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
- 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.
Top comments (0)