I know some Python and Java, and have a little C and C++ experience. I’m starting my second year and want to study data structures and algorithms alongside backend development. Is there a good reason to learn DSA in C++, or should I focus on a language I already know?
Should I switch to C++ for DSA, or stick with Python?
Answers
If Python is the language you can think most clearly in, use it to learn the ideas. DSA is about choosing and reasoning about structures and algorithms, not about one particular syntax. Check what your course and exams allow, then avoid splitting your attention unless there’s a specific reason.
Reply to this answer
I’d follow the language your university teaches or expects for assignments first. Java is a perfectly reasonable choice for DSA, and it gives you practice with types and object-oriented code. You don’t need to add C++ just because someone says it’s more fundamental.
Reply to this answer
C++ can be worthwhile if you want to learn it for other goals, or simply want another language challenge. Just don’t treat DSA as a requirement to manually manage memory. Modern C++ has tools and conventions for handling resources safely, and learning those is a separate task from understanding trees, graphs, or sorting.
Reply to this answer
For exams, use whichever language you’re allowed to write quickly and accurately. For practice, you can implement an idea in a second language now and then, but doing every problem twice may slow down your progress more than it helps.
Reply to this answer
Add your answer
Answers are reviewed before publication.
Related Discussions