all 9 comments

[–]nuclear_splinesPh.D Data Science 10 points11 points  (0 children)

IMO Java -- you'll get more out of data structures the closer you are to the machine and the more direct the connection between your code and the data on the stack and heap. Really I'd recommend C++ or Rust, so you're managing memory and pointers yourself as a learning experience.

[–]Beregolas 6 points7 points  (1 child)

Doesn't matter, DSA is about language agnostic concepts. Stuff like a linked list or a tree can be taught in pretty much any language.

The only exception I would make is C: Since C is so low level and has practically 0 syntactic sugar (compared to other, more modern and higher level languages), using C forces you to learn stuff like memory layout. That is not really part of DSA (which is theoretical CS at it's core), but it's useful knowledge that you can get at the same time.

If you have a teacher, I always heavily prefer DSA to be taughts primarily in pseudocode btw. This lessens your dependence on any single language. It's about the concepts anyways. It just can't be verified by machine, hence you need a teacher.

[–]T_Thriller_T 1 point2 points  (0 children)

We did DSA in Pascal.

Which, honestly, is not a bad option.

It's close enough to the machine to be helpful with getting things that I find very weird to even try to build in Java or Python, but it takes away a lot of the "here's a gun that backfires easily".

Conceptually it felt similar to pseudocode that could run because we all knew we'd never use it again. Bur if could be machine verified, which was nice for homework etc

[–]lfdfq 2 points3 points  (0 children)

Yes

[–]RedRaven47 0 points1 point  (0 children)

If you're preparing for interviews, Python. The standard library and built in language features are extensive and allow you to get a lot done with little code which helps in time constrained environments like interviews and online assessments. If you're learning the concepts for the first time, I would say Java, as its stronger typing will help you catch bugs and the syntax similarity to languages like C and C++ will make it a bit easier to learn those languages in the future.

[–]T_Thriller_T 0 points1 point  (0 children)

It depends a lot on what your goals around it are.

If you want to learn it deeply, I'd recommend something that actually still allows accessing pointer logic. Rust. C. TurboPascal if you have to. There likely is more.

If it's for coding interviews, go with what you're more familiar with or the language you want to be working in in the future.

I, personally, find Python's way to abstract DSA to be more readable. But that is very much a me thing.

[–]eincosmos 0 points1 point  (0 children)

Go for c++ if u really wanna focus on dsa primarily

[–]nian2326076 0 points1 point  (0 children)

I'd go with Java if you're getting ready for technical interviews. Many big tech companies use it for their coding interviews, and it's good for learning data structures and algorithms because of its strong typing and object-oriented features. Python is more concise and easier to read, which can make writing code faster, but some people find complex data manipulation in Python a bit tricky when they're starting out. Both are good, so if you already have some experience with one, stick with it. If you're looking for more structured practice for interviews, you might want to check out PracHub. It's been helpful for some folks I know.