r/cpp_questions • • 6d ago

OPEN C++ and Data structure

Which topics of C++ required for Data Structure??

3 Upvotes

10 comments sorted by

3

u/alfps 6d ago

Mainly pointers and dynamic allocation.

But also recursion, and the limits C++ place on recursion.

The main thing to keep in mind is that there is std::vector and std::string and std::unordered_map etc., so you don't have to reinvent those wheels where you need that functionality (as opposed to where the point is to implement it).

1

u/Aju_Baba16 6d ago

Thanks

1

u/manni66 6d ago

What do you want to do with data structures without algorithms?

1

u/Aju_Baba16 6d ago

I am a student and biggener. So i am confused

4

u/manni66 6d ago

It is of no use to have a data structure if you cannot do anything with it.

3

u/Independent_Art_6676 6d ago edited 6d ago • Popcorn

classic, beginner level:

simple functions
references (as function parameters and access usage)
basic OOP (at least able to add functions to a class)
basic pointers (able to allocate and destroy an entity)

The beginner stuff is largely just to learn as C++ has built in almost ALL the major useful data structures already except for nonlinear graphs (trees, graphs, etc) and oddities. The above would let you make like a linked list, stack/queue, hash table, etc. If you wanted to you can avoid fooling with pointers and use a vector, with its indices as-if pointers, for these, if you know vectors pretty well.

better, usable results beyond beginners and classroom junk (eg make your own STL tree class for a job):

templates, inheritance, and solid OOP knowledge
smart pointers
good working knowledge of STL, and what an STL container must have to work with algorithms/etc
that means understanding iterators well
algorithms (sorting, searching, recursion, more)
memory management (recycle deleted items, keep data in a solid block, etc)
some performance knowledge

1

u/alfps 6d ago

❞ almost ALL the major useful data structures

I very much miss a cursor gap thing. Also rope for strings, which was in STLPort. But it may be just a feeling, because I don't implement these: it's very much possible to make do without them.

2

u/n1ghtyunso 6d ago

the question is too broad.

1

u/Discordbothost 6d ago

to add: a class with a destructor, since a hand-written list or tree leaks fast without one. references so you aren't copying nodes, templates once the container should hold any type, and operator overloading only if you write an iterator.

1

u/ConnectAffect2346 6d ago

For c++ data structures you need to know basics from c++ (functions, loops, conditional statements, structures, arrays and libraries) and ofcourse inside basics are pointers and file usage but i purposefully put them outside of brsckets since they are fundamental as you can use some data structures with array implementations and with pointer implementation, through data structures you will also learn how to analyse time complexity of a program and with that you can use a priori and a postieri methods which come in handy in analysis later since data structures are the beginning and after going through basic data structures you will come to algorithms as u/manni66 mentioned, they will be very complex and will include in few examples file usage or fstream library and they may not, it all depends but ultimately it will be very hard and also one thing to keep in mind after learning data structures is to try to use them in some examples since if you haven't had object orientes programming then you surely will have it soon and then your programs will depend on implementation of those, now here are a lot of tips but primarily it is all to just prepare you for what comes next, after all that you will have easier time later since this is the base of programming mindset that you are building with these subjects, i hope this helps 🙂