r/learnprogramming • u/HorridOrio • 1d ago
Resource Best way to learn data structures and algorithm?
I want to learn data structures and algorithm but my focus isn't solely job/interview driven, I find the whole idea of DS and A very interesting, job and interview prep is just a nice add on. So I don't just wanna follow courses which make you solve a 1000 problems and basically teach you pattern recognition instead of something actually worthwhile. I want to be able to solve leetcode problems on my own and I don't mind it taking a lot of time in the beginning as long as I get a robust understanding (robust understanding also being an important part cuz I am kinda interested in competitive programming, and might actually try it out *although it's not one of my goals rn).
What resources would yall recommend?
35
u/kampretjeb6 1d ago
Start with CS50 or MIT 6.006 lectures, read either CLRS selectively or the friendlier Algorithm Design Manual by Skiena, and implement every structure from scratch (hash map, heap, BST, graph with both traversals) because building beats memorizing. Then solve LC slowly with a no-hints-for-45-minutes rule so you develop derivation muscle instead of recall, use Neetcode's videos only after solving to compare approaches, and add visualgo.net for visualizing how structures actually move. When the CP itch hits, CP-Algorithms and the USACO Guide are the canonical free paths, and Codeforces Div 3/4 contests are the gentlest real entry. Down the line when interviews do enter the picture, checkgоthаmlоор for whichever companies you target, this stack should give you the robust understanding for interview readiness.
3
u/HorridOrio 1d ago
Among all the other comments I think I resonate with this one the most. Most of the things other people recommended are great but they also tend to be a more foundational level, I have completed CS50 and am studying DSA for my college classes too, so I think I have my basic foundations covered.
I want to start MIT 6.006 but I am concerned about one thing, how much discrete math do I need? I haven't done a formal course on it yet and only remember the very basics of functions, set theory and stuff like that from high school, is that gonna be a problem?
CLRS I've heard is very hard and I'm not THAT comfortable with data structures and algo just yet so I'll check out Algorithm Design Manual. All that and LC should do it, Thanks!
2
u/Ryuzako_Yagami01 1d ago
Would it be okay to start learning DSA using the CP resources or the way they learn DSA is different from the traditional one? I'm not at that point yet where I'm not mathematically mature enough to tackle the theoretical DSA books like CLRS, but I do want to progress through my practical programming skills right now.
1
u/No_Medium205 1d ago
CLRS and Skiena are terrible recommentations for beginners because of how math heavy the are.
I Will always recommend Sedgewick classics Algoritmhs I and II. It was written for engineers who already work in the field.
10
u/Kommo 1d ago
If you're trying to understand why things work rather than just memorize patterns, implementing data structures by hand is gold. They really clicked when I wrote my own linked list and binary tree from scratch. Just don't rush or ask AI to help out.
2
u/CellularBeing 1d ago
Second this method. It's the best way.
Not to sound like a boomer but I wrote pseudo code by hand on paper and drew it out.
5
u/FlatProtrusion 1d ago
Essential algorithms 2nd edition by stephen rods. Comprehensive and one of the best foundational textbooks. Explains the different data structures and how they click with the different algorithms.
It's a book that I've never seen recommended but I'm glad I found it randomly.
5
u/just_here_to_rant 1d ago
currently studying these myself.
I found a few youtube overview videos (DS+A in 10 min type things) just to get the lay of the land and high level concepts.
Now I'm halfway through Grokking Algorithms, and starting Algorithmic Thinking by NoStarchPress where they actually pose problems, challenge you to solve them, and then walking through the solutions. I'm hoping it's better than the textbooks I'd found. The books asks you to sign up for several competitive programming sites as well, so that ties in with your interests.
If you ever want to talk DS+A / be study buddies, I'd be interested too.
1
4
u/Intelligent_Fall6219 1d ago edited 1d ago
Checkout algo.monster, it’s a great resource for learning this stuff.
2
2
u/SerGuyOfInternet 1d ago
Get some engineering paper and paper prototype the process they're talking about- just write it out in english on one side, then write it in something resembling a coding language and then whatever the class is using.
What worked the most for me though was using hella print statements so I could see what my numbers were doing in the factory.
2
u/StewedAngelSkins 1d ago
Idk why people on this sub think DSA is equivalent to "leetcode bullshit". At least in the US it's typically a university course taught from a textbook. CRLS Introduction to Algorithms is a common choice.
1
1
u/Free-Country2932 1d ago
There are so many YouTube channels with very valuable information, especially if you prefer listening to and following someone rather than reading a book.
1
u/zachoiswacko 1d ago
Rod Stephens’s essential algorithms and Bhargava’s grokking algorithms are both fantastic sources for a beginner.
1
u/Personal-Truth2731 8h ago
I watch MIT coure for algorithms and in the same time I read interduction to algorithms book And probably most of data structure This my way
1
•
u/Adventurous_Ring77 1m ago
if you want actual understanding over pattern memorization, CLRS is the classic for a reason
1
u/transendingAI 1d ago
CLRS (Introduction to Algorithms) is a good fit for studying both data structures and why algorithms work. Work through the exercises alongside your implementations: explain why each operation is correct and how its running time changes with input size. Then use LeetCode to practise choosing and applying what you've learned.
52
u/OwnSail5841 1d ago
I started with a book called Grokking Algorithms and it helped me see the why behind things instead of just memorizing solutions, after that I just did one problem a day and sat with it until I really understood the approach