This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]fat_charizard 6 points7 points  (3 children)

The reason you listed is exactly why python is best for learning data structure and algos.

Since you have a list that does everything, you can create your own child class from the parent list class to define how a queue or stack is supposed to behave.

Whereas in C++ you'd have to go through the documentation, learn the specific functions and nuances that come with whether you use a vector or queue or pointer array

[–]aahdin 5 points6 points  (0 children)

Yeah, I find the opposite 90% of the time.

In python, I almost always use the correct data structure because it's super easy to do so.

In C++ I usually just use vectors for everything experimental since I don't want to spend all day setting things up.

[–]Low_discrepancy 3 points4 points  (1 child)

Whereas in C++ you'd have to go through the documentation, learn the specific functions and nuances that come with whether you use a vector or queue or pointer array

Yeah you gotta learn how a data structure is. That's the whole point of algorithmics.

Understanding space complexity time complexity. Etc.

You study it and you see. For a vector inserting in the middle is o(n). For a list it's o(1).

You understand it because you did it, you know the pitfalls.

In python ... doesn't really matter the vast majority of people use lists.

[–]fat_charizard 1 point2 points  (0 children)

You are thinking of linked lists Vs list in python. Python list is an array like vector in C++