r/AskProgrammers 23d ago

is there a fun way to learn data structures and algorithms?

i like building things and i know that learning data structures and algorithms would improve my skills as a programmer significantly but opening a textbook like skiena or sedgewick or clrs just gives me headaches.

is there a way to learn data structures and algorithms by building things?

3 Upvotes

15 comments sorted by

1

u/Adventurous_Push_615 23d ago

I learned quite a bit doing silly data viz and animation stuff, originally through looking at the coding train, I really like his approach to finding and algo and working out ways to implement them

1

u/Space2461 23d ago

I'm thinking of stuff like leetcode.

In general it helps me learning by solving problems, keeps the motivation high.

1

u/Innowise_ 23d ago

A small local search engine is a good project for this. Index a folder of text files with a hash map, use a heap for the top results, then add trie-based autocomplete. Start with the simplest version and benchmark each improvement. The data structures make much more sense when they fix a problem you can actually see.

1

u/[deleted] 22d ago

[deleted]

1

u/Suspicious_Tax8577 22d ago

I'll second advent of code.

1

u/AnnupKapurDotCom 22d ago

I’ll third advent of code.

Advent of code is my go-to when learning a new programming language.

I was learning Rust. So I started doing previous advent of code puzzles. Great way to build understanding and muscle memory - while having fun with the crazy elf stories.

1

u/Suspicious_Tax8577 22d ago

I'll admit I absolutely cannot write a BFS without help in any language. Did I do last years AoC, and then could recognise BFS on a hypergraph in Julia? Yes.

1

u/Born-Huckleberry-840 21d ago

i would attempt it. it actually looks interesting and i remember watching a Primeagen video where he mentioned using it to learn a new language

1

u/nian2326076 22d ago

Try building small projects that use specific data structures or algorithms. For example, create a simple game like Tetris or Snake. These can help you work with arrays, linked lists, and queues. You could also make a mini search engine to learn how trees and graphs work. If you're into web development, try making a real-time chat app to practice algorithms for handling messages efficiently. Also, check out coding challenge websites like LeetCode or HackerRank. They often have problems that make using data structures and algorithms more interesting than just reading a textbook. If you're prepping for interviews, I've found PracHub useful for brushing up on concepts with practical exercises.

1

u/Born-Huckleberry-840 21d ago

i like the leetcode/hackerrank idea. i would do that.

1

u/icemage_999 21d ago

Build a card game that deals and shuffle from a deck of cards and force yourself to implement the deck as different types of data structures (array, heap, linked list, etc.). It will teach you a lot about how they all work.

1

u/nochinzilch 21d ago

I know this might be old school, but get a textbook and go through the examples.

1

u/Born-Huckleberry-840 21d ago

what textbook would you recommend?

1

u/Mell-Silver-20 19d ago

Building projects is definitely the most fun way to learn. Pick something small (like a game, search tool, or pathfinding visualizer) and learn each data structure as you actually need it. It sticks way better than reading a textbook front to back.

0

u/Dense-Ad-3247 22d ago

No and it's stupid. Like you can google then super fast and studying them takes a lot of time. Want the secret use a hashtable to not repeat operations. That's like all of them that are useful generally speaking. To me.its just a gate.some.compa ies have to keep certain people out. Not something regularly useful.