How to Master Data Structures and Algorithms for Coding Interviews?

== What is Data Structure?
== Why Data Structures And Algorithms Are Important For Placement?
== How to master DSA for coding interviews?
== How To Approach a DSA Problem and Optimize?


What is Data Structure?

Data structure is a way of storing and organizing data in the disk space of the computer in a way that the data can be retrieved and used easily. So anyone with good understanding of data structure, they can organize and store data in a proper manner. Data structures are the crucial part of many programs or algorithms of a computer application.

Algorithms are nothing but a set of rules or logic used for solving a problem. When you are developing an Algorithm, you should aim to develop in a way that it should consumes lower memory space and lesser time to execute. The efficiency of an algorithm is determined through Space complexity and Time Complexity. Time complexity is nothing but total time required by the program to run till its completion. Space complexity is the amount of memory used by the algorithm to execute and produce the result.

Why Data Structures And Algorithms Are Important For Placement?

Top tier companies Amazon, Facebook, Microsoft, Google etc. have been working day in and day out for improving user experience and managing data most efficiently. That is where Data Structures and Algorithms come in. They are key building blocks of important algorithms. So, in order to developing an efficient product, Data Structures and Algorithms skills are must. And that's the reason why the interviews conducted by product based companies are centered around analyzing the candidate’s knowledge of algorithms and data structure. They look for candidates having a strong grasp of algorithm skills.

Data structures are used in all areas of computer science such as Artificial Intelligence, Robotics, Graphics, Database System, Operating System etc.

And, with rapid evolution of technologies and an increasing amount of data, they will never go out of demand.

They not only help you land a high-paying job, but also help you to sustain and do well in your job.

Strategy to learn Data Structures /How to master DSA for coding interviews?

So, now we know that Data Structures and algorithm is of the most important subject for placements in IT companies. To learn DSA There is no shortcut or easy way but there is definitely a smart way. So, let's discuss smart strategy to learn Data Structures.

There are many topics to learn, so I would suggest to divide your DSA journey into three phases

Phase 1 - Basic Data Structures Concept

In this phase, you can start covering the fundamentals of the following data structures and concepts

- Understand the concept of Algorithmic complexity
- Arrays
- Hash Tables
- Linked Lists
- Stack
- Queue
- Sorting Algorithms (Bubble, Insertion, Merge, QuickSort, Counting Sort)
- Standard Binary Search

In order to learn each of these concepts, instead of going through online articles. I would suggest to study from some comprehensive book. These online articles are mostly scattered and incomplete.

And, if you really want to use a website then you can use GeeksforGeeks. It has a large amount of quality content.

There are a bunch of courses as well which you can take online

You can check platforms such as Logicmojo , Udemy, Coursera for these courses.

So to begin with, take one topic at a time, learn the theory part first, try to understand basic operations such as insert, delete, search, traversal and its complexity.

Learn advantages and disadvantages, study it's applications and understand about memory allocation.

Once you are comfortable with everything above, start practicing and solving problems on online platforms. The more you practice, the more you learn. Coding is all about more and more practice.

One should solve 5–6 problems from each topic to have a significant control over the topic.

For this, you can use a book such as "Cracking the Coding Interview", It features nearly 200 programming questions and solutions asked by Amazon, Google, Facebook etc.

There are many online resources as well with a huge list of problems that you can practice. And they are

Leetcode
HackerRank
InterviewBit
Codechef

You should also work to optimize your code and compare with the solutions of the same problem people have given on these platforms

Phase 2 - Advanced Topics

Now, let’s learn some advanced topics in this phase such as

- Trees (Binary Tree + Binary Search Tree + Binary Heaps)
- Backtracking
- Graphs
- Dynamic Programming
- Greedy Algorithms.

So, you need to learn theory first.  Again, I would recommend the book for theory instead of online articles.

Once you are done with theory, start solving problems from online platform. You can follow the same process as you followed in the Phase 1.

Phase 3 Participate in contests

Once you get comfortable, do take part in contests held on Codeforces. It is a website that hosts competitive programming contests. And programmers from every corner of the world participate. They will help you improve your speed and confidence.

Remember, If you want to master DSA, you have to practice on a daily basis to build and improve your confidence.

How To Approach a DSA problem and Optimize?

- First, give yourself enough time to clearly understand the given question.
- Breaking down the Question
- Figure the data structure you are going to use.
- Write down a pseudo-code in simple English.
- Replace Pseudocode With Real Code
- Try to find a room for optimization
- Estimate the time and space complexities
- Check for any repetitive or unnecessary loops
- Check for any extra step or function you can take out