How to Study Data Structures and Algorithms [Technique Tuesday]
Almost nobody talks about this. That changes today
So you want to be a software engineer at Google? Maybe you’re studying these data structures for your courses, or to implement certain solutions/systems. Whatever your reasoning, you're decided to study Data Structures and Algorithms. People recommend DSA as the single most important step in your interview preparation journey. However, they almost never tell you how to study them. Even worse, some give you bad advice (like, “Use Leetcode to study DSA”). In the surveys I leave for my followers, one of the common requests is always, “How can I study DSA.” One reader even left this very interesting comment-
If nothing else, this should go to show you how bad the advice for studying DSA left by the experts is. Not to worry, I’ll cover why the advice online is bad, and how you can approach DSA to expel the ghosts.
Why DSA Advice online is trash
As always, to understand how to do something, it is important to understand where common advice fails. That can help you understand how to avoid similar mistakes in the future.
The most common advice given is to use Leetcode as a way to learn DSA. They tell you to do a lot of Leetcode questions by the topic you’re struggling in and you will somehow become a Data Structure expert. As someone who has helped a lot of people go from novices to experts, I can tell you that this advice will just waste your time. Why?
Think back to how we learn anything new. Remember, solving Leetcode/Coding Interview questions is a skill. To make things easier, let’s take the example of learning a language. We first learn the individual components of that language (letters, words, tenses), and then we focus on creating sentences. Imagine how hard learning a language would be if you had to try speaking the language while you were learning to identify the letters.
Think back to working on your DSA. Now, do you see why you struggle, with DSA? Trying to use Leetcode questions (which are like putting together sentences) is very hard when you’re not familiar with the basic theory about the Data Structures(alphabet and basic tenses).
How to Fix This
I could just cop-out, and point you to a few videos and resources that will show you the DSA. And those are unbeaten for learning the mechanics of the Data Structures. However, they would not help you with a fundamental connection.
Most online tutorials are great for explaining the hows of a data structure (how to implement a Data Structure, Main operations, Time Complexity) but they don’t tell you the why (where the data structure is useful). For simpler Data Structures like Stacks, LinkedLists, Queues, and Arrays, this is not a problem. That is because we use them very frequently, and these Structures are not too hard to visualize. Our minds are naturally suited for such Linear Data Structures. Take a look at the following message I recieved
Look at the DS and procedures he mentions. Graphs and Trees are not linear Data Structures. That means, our minds are not naturally suited to them. So trying to rush into Leetcode questions that consist of these Data Structures will be a giant waste of time. That is exactly what my reader(and many others) have experienced.
Instead, the answer lies in taking it slow. I know this is not the sexiest answer since people are trying to ace their interviews in 6 months. However, this approach is short-sighted. It might work for getting past your interview, but you will forget most of what you learned by the end of the process. And it won’t help you develop the mastery in using and identifying these structures in your solutions.
So how do you take it slow? As you study a Data Structure, take time to understand the history of the Data Structure, and how different components were developed. You don’t need a Ph.D. in this, just a working understanding of how various concepts are linked. Remember, each of these Data Structures and Algorithms was created to solve a particular problem. Not understanding how they solve the problems, will just handicap your own learning.
Instead, take it slow. Learn how each aspect of DSA is linked to another, what problem it solves, and what the story behind its creation is. That will get you to be extremely comfortable with DSA, far beyond the level you would get if you wasted time on the inefficient nonsense being peddled these days. Once you get this familiarity, you can move into Leetcode questions, and your learning will be accelerated. For best results, use the approach shown here. To learn more about about how you can slow things down effectively, and really max out your theoretical learning, check out the post, How to go From Zero to Hero in 7 months.
This will not be enough for the really hard components like Graphs, Dynamic Programming, and Heaps. These are topics that require some specialized preparation. I have already covered how to spot and handle graphs here and will do dedicated articles on the others soon. Make sure you check-in for the Math Mondays and other days to not miss out.
In the comments below, share what topic you want to focus on next. I’d be interested in learning and will cover them. To learn more about the newsletter, check our detailed About Page + FAQs
If you liked this post, make sure you fill out this survey. It’s anonymous and will take 2 minutes of your time. It will help me understand you better, allowing for better content.
https://forms.gle/XfTXSjnC8W2wR9qT9
Happy Prep. I’ll see you at your dream job.
The One who sees Graphs everywhere,
Devansh <3
To make sure you get the most out of Technique Tuesdays, make sure you’re checking in the rest of the days as well. Leverage all the techniques I have discovered through my successful tutoring to easily succeed in your interviews and save your time and energy by joining the premium subscribers down below. Get a discount (for a whole year) using the button below
Reach out to me on:
Instagram: https://www.instagram.com/iseethings404/
Message me on Twitter: https://twitter.com/Machine01776819
My LinkedIn: https://www.linkedin.com/in/devansh-devansh-516004168/
My content:
Read my articles: https://rb.gy/zn1aiu
My YouTube: https://rb.gy/88iwdd
Get a free stock on Robinhood. No risk to you, so not using the link is losing free money: https://join.robinhood.com/fnud75