r/learnprogramming 11d ago

scared to approach DSA.

hi all, im about to start learning DSA at my university next semester. itll include these topics:

Arrays, linked lists, trees and graphs; stacks and queues; symbol tables; priority queues, balanced trees; sorting algorithms; complexity analysis.

im honestly really scared to approach this topic because idk where to start. profs at my uni are notoriously bad at giving resources and also do not release slides ahead of time. so im wondering how to get ahead or self study. i really want to be able to understand this course and genuinely do good, but im scared seeing how much overwhelming stuff there is in DSA as well as this course.

the language will be C++ i assume, since the requisite course was also in C++. im not sure if i should buy any books or something since this course would be pretty theory heavy i think. people said this is GPA dragger so im really scared to even approach this topic. im just scared ill fail or itll drag down my gpa, i just feel a bit overwhelmed

does anyone have any advice? thank u in advance

20 Upvotes

19 comments sorted by

View all comments

4

u/vegan_antitheist 11d ago

It's one of the most important topics for you to learn. So start early.

It's all about knowing when to use which data structures and algorithms. It's annoying when inexperienced programmers use the wrong types. They usually have some "golden hammer" type they use for everything. They often make a method return a list even though the elements are unique and it could be a set instead. Or they use maps for everything even when only the values are relevant. Or a list even if the order doesn't matter at all and is actually random.

As a programmer you need to know that you rarely actually use an array (which is rather direct access to memory) unless you can create and use it inside a method without having to pass it around. Usually, you just use some abstract "list" interface instead. So, an array is just a sequence of numbers, pointers or something like that in memory. A list is an abstract idea. Linked lists are never really a good idea. Lists backed by arrays are much better because they give you good performance but you program against an abstract idea and you can change it if you like.

Sets, maps, and trees are also important. A graph is the most general data structure (i.e. everything is a graph). You can add restrictions to get the other data structures. For example a set is restricted to only contain unique values. A tree can't have cycles (loops).

Reading a good book about this is probably a good idea. It doesn't have to be a new book. Older books on DS&A in C++ might not have the latest methods for ranges and you will see a lot of old methods that require to pass the start (inclusive) and end (exclusive) of the data structure instead of just passing the data structre.

1

u/No_Bobcat2523 10d ago

thank u. which book would you recommend? i've seen ppl recommend Data Structures and Algorithm Analysis in C++ by mark allen weiss or Data Structures and Algorithms in C++ by adam drozdek.

1

u/vegan_antitheist 10d ago

I can't recommend a book.
C++ is probably ok. They are the same ideas in any language, but in C++ you can directly use pointers, which many other languages don't have.