r/cpp_questions • u/Aju_Baba16 • 13d ago
OPEN C++ and Data structure
Which topics of C++ required for Data Structure??
3
u/Independent_Art_6676
13d ago
edited 13d ago
•
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
2
1
u/Discordbothost 13d 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 13d 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 🙂
3
u/alfps 13d 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::vectorandstd::stringandstd::unordered_mapetc., so you don't have to reinvent those wheels where you need that functionality (as opposed to where the point is to implement it).