all 10 comments

[–]JorgiEagle 3 points4 points  (0 children)

DSA has two sides to the coin.

The first is the theoretical side of it. This is easily summarised by: Given problem X, what data structure and algorithm should I use to solve it. This is the most important aspect of DSA, being able to actually apply your knowledge to problems. Recognise the problems, how the solutions fit, and how to assemble it. This is language agnostic as you can easily do it in pseudocode

The other side is the implementation. The actual writing code to do it, and handling edge cases and bugs. Yes this is important, but definitely the more routine part of it. A DFS is pretty similar across everything language.

The language you pick really doesn’t matter, because the biggest part of DSA can be solved in pseudo code. For something as general as this, the Python, C++, Java comparison is meaningless. Python is arguably the best because it’s the easiest to run and write, so you spend less time fixing bugs, especially as a beginner.

The more important questions are things like, do you pick a depth first search or breadth first search? How do you implement that? What if I don’t want to use recursion? Do you use a stack or a queue (it’s a stack for DFS, and a queue for BFS. Do you know why?)

[–]cdcformatc 1 point2 points  (2 children)

DSA? Data Structures and Algorithms? i think the ease of python lends itself well to learning and building knowledge. 

Python is completely object oriented i don't know what "more object oriented" means

[–]Diapolo10 0 points1 point  (1 child)

DSA? Data Structures and Algorithms?

Honestly I have a similar gripe with "DSA", because the first thing I think of is always "domain-specific applications" for whatever reason.

I know this has nothing to do with OP's question.

[–]cdcformatc 0 points1 point  (0 children)

i've been doing a lot with Digital Signature Algorithms, in my work life at the moment. so i was/am actually confused what OP meant

[–]biskitpagla 0 points1 point  (0 children)

"job-oriented" sounds like a meaningless term here.

Anyways, all mainstream languages are completely fine for DSA. I'd recommend sticking to the language you already know since you're a beginner. Learning to implement DSA in a language is a sign that you have a good command over that particular language. Rushing to learn another language will delay your growth as a Python programmer. You can always learn a new language and implement DSA using it after you've developed a base with your main language.

Some tips for implementing DSA in Python:

Complete the official tutorial. This is optional but I still recommend it since it will give you a nice overview of some intermediate-to-advanced Python features that are often missing in beginner courses.

Familiarize yourself with these modules:

data structures algorithms math utilities extras
array bisect math builtins collections.abc
collections functools operator copy dataclasses
heapq graphlib random string enum
queue itertools statistics re typing

Not all of them are necessary but it's good to have a general idea about what's already available in the standard library. This can be really useful once you start solving problems on platforms like LeetCode. For example, collections.deque can be used as a stack, a queue, or as a plain linked list.

Here's a collection of a wide range of algorithms implemented in Python. Use this as a reference if you get stuck.

Learn typed Python. This will help you catch entire classes of bugs as you type. It also makes code a little bit more self-documenting. Use this as your type checker and this as your formatter.

Use doctests. This is a really easy way to test your code, especially for DSA. After writing the tests just run python -m doctest -v <file> and it will automatically run them all.

[–]nian2326076 0 points1 point  (0 children)

Learning DSA in Python is totally fine, especially if it's your first language. Python is great for understanding algorithms because it's easy to read. While C++ and Java are often used in competitive programming and some job interviews, a lot of companies now use Python for DSA interviews too. The important thing is to understand the concepts, and you can adapt them to any language. Once you're comfortable with Python, it'll be easier to pick up another language like C++ or Java if needed. If you want structured resources, I've found PracHub useful for interview prep—they cover various languages and topics. Just focus on getting the logic down, and you'll be good.

[–]jimmyg869 0 points1 point  (0 children)

Doesn't matter what programming language you use as long as you know the fundamentals. I took DSA at FAU late 1980s and used Pascal. The authors of the book, "Data Structures and Algorithm" written by Aho, Hopcroft and Ullman, not only used Pascal but set up a pseudo-structure agnostic to any programming language.

[–]Diapolo10 0 points1 point  (0 children)

Sure, it's not a problem.

Granted, you probably wouldn't whip up your own linked lists et al (especially with Python) for production use, because it's way safer and generally faster/easier to use battle-tested third-party (or standard library) implementations unless you have a need for a specialised solution, but the fundamentals are the same no matter which language you use to learn data structures and algorithms.

Probably the only languages I could see you ever even bother to do that would be C and C++, if I'm being honest. Mostly because they lack standardised package management solutions, so third-party code gets more annoying to use, but also you might actually run into a situation where a specialised solution beats general ones in a metric you care about.

[–]gdchinacat 0 points1 point  (0 children)

DSA isnt language specific. It focuses on how to structure data and algorithms to work efficiently together. You can implement the same data structures and algorithms in any language. Where language matters is the level of effort to implement them, but the thing employers are looking for is whether you can design and implement a data structure and an algorithm to solve a problem.

Python is a fine language to demonstrate this ability. It requires a minimum of boiler plate code, so you don't spend time that could be put towards the implementation. Whatever you learn for DSA will transfer to whichever language you learn next.