DEV Community

Cover image for DSA by Mitul in C++, Python, and Java (Part 1): Introduction to Data Structure and Algorithms
Shahriyar Al Mustakim Mitul
Shahriyar Al Mustakim Mitul

Posted on

DSA by Mitul in C++, Python, and Java (Part 1): Introduction to Data Structure and Algorithms

What are Data Structure?

Data structures are different ways to organize data.

Image description

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

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

Let's know some real life example .

  1. Companies like Facebook, Google Hangout use compression algorithms to transmit live videos .

Image description

  1. Google maps use Dijkstra's algorithm.

Image description

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

Image description

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

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

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

Image description

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

1.Simple recursive algorithms general recursive codes.

  1. 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
  2. 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

  1. 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)