# A Step-By-Step Guide to Becoming a DSA Expert

The best way to strengthen your logic is by drawing the concepts and problems on paper. Even if it takes more time in the beginning, persist with it because it is going to get easier

The world will witness different waves of technology, today it is IoT, AR, and VR, a few years ago, it was the internet, and years from today - We may be witnessing a robot revolution.

But something that will be fundamental to all across these industries - The knowledge of data structures & algorithms.

Frameworks might come and go, but DSA will be there for eternity as they're the basics of computer programming.

And that's the reason why most of the interviews for developer and engineer roles are heavily centered around DSA problems. So much so, that DSA is synonymous with interview problem-solving.

On the other hand, mastering DSA can be an uphill task. The reason why most of the students choose to skip it in their college days. Plus there's this myth that you don't really need to learn DSA for developer jobs, which is of course a myth.

To be a top-notch computer programmer, you must learn data structures and algorithms.

We believe anything can be learned if you are willing to learn and have a sequential and strategic approach to it.

And that's why we've prepared this step-by-step roadmap that will simplify the process, and if you follow these steps with all soul and heart, you can very well become a DSA expert.

## Step 1: Pick a programming language

If you're just starting out with data structures and algorithms, you need to first choose a programming language and understand its syntax and semantics.

Focusing on the theory is important but at the same time, you need to implement it in the form of codes.

The question is: Which programming language should you pick? To that we say, pick any language you want. Language is just a way to communicate with the computer.

But make sure that you focus on one programming language and master it before moving on to DSA.

Here are a few questions you can ask yourself while picking a language:

- What’s the purpose of learning? Is it for competitive programming, creating projects, or cracking interviews?
- What are your long-term career goals? — Are you trying to learn DSA for a particular company’s interview?
- Ease and Comfortability
- Usage of the language- How common it is in the industry?

At Masai, students use JavaScript and Java path is also introduced from Unit 4 for students who're interested in the back-end.

## Step 2: Understand the fundamentals

Data structures are the various specialized formats in which we store and organize data, so we can efficiently perform different operations on it.

Algorithms are the set of instructions that tells the program how to carry out that operation.

To learn DSA, you need to prepare an order of the concepts you're going to learn. Here's a suggested order:

**Data Structure;**

**Algorithms:**

- Searching
- Sorting
- Hashing
- Prefix sum
- Suffix Sum
- Greedy
- Recursion
- Backtracking
- Tree and Graph traversals
- Dynamic Programming
- Advanced algorithms on tree and graph

After you've set the order, you can start learning the individual topics one by one.

Data structures and algorithms are purely based on logic and applied in problem-solving. So, mugging up the codes is not going to take you far. You need to switch your imagination on and start picturizing things even before you pick up your pen or finger.

**Here's a 3-step process you can take to strengthen your fundamentals:**

1.) Read

2.) Visualize & Draw

3.) Understand and code

The best way to strengthen your logic is by drawing the concepts and problems on paper. Even if it takes more time in the beginning, persist with it because it is going to get easier. With more and more practice, your mind will form patterns.

If you look around, there are multiple ways we use data structures and algorithms in our real lives. From storing books in a library to finding words in the dictionary, we're surrounded by them. Take inspiration from these real-life situations and incorporate it into problem-solving.

## Step 3: Understand Time and Space Complexity

The very purpose of learning DSA is to write efficient and optimized code. What does optimized code mean?

Suppose, you were in a bank and you had to make a list of the top 20 saving account holders out of 200 million customers. The bank wanted to provide incentives and special plans for its top 20 customers. Also, keep in mind that the data kept changing as other customers invested more into their accounts.

What approach would you take? How would you store and rank the data within the shortest possible time?

That's where you need to understand time and space complexity.

The time complexity of an algorithm refers to the time taken by the algorithm to run. Similarly, the space complexity determines the amount of space or memory occupied by it.

Your goal while solving a problem should be to reach a solution that requires the least amount of time and space to run.

You might not get the cleanest code for every problem in the beginning, but with time you'll get there.

## Step 3: Depth vs breadth approach

As Bruce Lee once said, *"I fear not the man who has practiced 10,000 kicks once, I fear the man who has practiced one kick 10,000 times."*

This holds true for programming as well.

Students practicing 500 DSA problems and yet failing at interviews is a very common scenario.

We call it the 'breadth-only' approach.

Recruiters test deep problem-solving skills and, at an efficient speed. To prepare for that, you need the depth-first approach.

Even if that means solving 50 problems instead of 500. Analyzing a problem in depth enables you to:

- Understand the root of the problem
- Solve at a better pace
- Write clean and optimized code as you have practiced similar problems a number of times
- Understand which data structure or algorithm to use

If you start solving similar problems in depth you'll implement different methods to do it, and you'll start seeing patterns.

Once you've solved a sufficient number of problems in depth, you can take the breadth approach and solve as many as you want.

One magical thing that'll happen is- You'll get the tremendous speed and most of the problems will be close to the core set of problems you solved in depth.

You need to curate a list of at least 1oo core questions

## Step 4: Pseudo Code & Dry Runs

Dry runs refer to the process of manually working through the code to check the value of variables at each step. It means checking what happens for i=1, i=2, i=3, and so on.

It might take some time and effort but it is detrimental to understand how the code works and in turn strengthens your logical thinking.

Using pen and paper, you need to draw dry run tables containing the changing values of tables

Draw dry run tables that demonstrate the shifting values of the tables with a row for each line the program runs.

You can also try different starting cases to understand different core problems.

## Step 5: Spaced Repetition

You solve a few questions today but happen to forget the solution after 20 days. How can you not let that happen? Enter - Spaced repetition.

It's a learning strategy where you review the lessons repeatedly after increasing intervals.

Spaced repetition is used across the board for learning and improvement.

You do the problem today, review it at an interval of 7 days, review it again at an interval of 14 days, and then a month, and so on.

The increasing interval time will train your brain memory to store things longer, quite similar to how one increases their deadlift reps in gyms.

When you see a problem you'll immediately be able to break down the components and re-create the solution. It's the best way to ensure that you don't forget the old topics while you're learning new ones.

## Step 6: Isolate reusable techniques/codes

The more problems you'll solve, the more and more patterns you'll find. It's time to be smart and optimize the problem-solving process. How?

Let's say you solved 10 problems that used a recursive algorithm. Now you can isolate the recursion code and use it in similar problems repeatedly.

Over time, you will have that code like a preset in your mind and your eyes will instantly light up when you see similar problems.

You can practice this with other common techniques such as binary search, depth-first search, etc.

Here are a few important benefits of the isolating technique:

- You can restructure the code to solve new problems, thus coding at a fast pace.
- You’ll be able to code without many compiling or runtime errors

## Step 7: Prepare for Interviews

Once solving the core problems has become second nature to you, it's time to focus on the breadth approach. Solve as many questions as you can in random order.

That's how you'll be facing problems in interviews. Start checking common interview questions on the web and try solving them in the most optimized ways possible.

Keep in mind that your focus should still be on getting better at DSA, and not on interviews and placement.

Websites like HackerRank, and LeetCode organize leagues and competitions where you can enter and solve a vast array of DSA questions and strengthen your profile.

It will act as ‘Proof of work’ and a demonstration of your problem-solving skills while applying for your dream jobs. Besides, we all love games and tournaments, don’t we?

It will also build tremendous consistency and credibility.

(Know more about getting started with coding competitions here)

Even after you've mastered DSA and moved on to other topics, revisit DSA problems and make sure they're fresh in your mind. Remember spaced repetition?

After you have gained confidence in the implementation of DSA, one of the better exercises for you would be to read a couple of books related to programming. They’d help you get the bigger picture and a comprehensive understanding of the concepts. (Here’s a list of 5 such books to brush up your skills)

## Final Thoughts

There it was! A step-by-step guide to getting better at data structures & algorithms.

If you follow these steps, you’ll definitely be ahead of the game.

Another option you can pursue is to learn and train with a skilling institute like Masai. In the 7-month full-stack web development course here, you’ll learn DSA from scratch and in the most structured of ways, along with all the other concepts in web development. Students solve daily DSA problems and also sit for mock interviews during the program.

After completion of the course, Masai provides job opportunities in developer roles in top tech companies such as Dream11, ShareChat, Ola, etc. to name a few.

And, all of this at zero upfront fee. Yes! You don’t pay anything for the course unless and until you get placed with a CTC of INR 5 LPA.

So, what are you waiting for?