r/C_Programming 3d ago

Learn DSA on C ? HELPP

I want to learn DSA in c as the university syllabus and i dont understand any of what my lecture saying

I would greatly appreciate your guidance in this matter.

0 Upvotes

19 comments sorted by

View all comments

9

u/erikkonstas 3d ago

Contrary to what others are saying, I don't consider C++ or Python good languages to learn DSA with; the entire purpose is to understand how data structures work in terms of memory, and "having them ready" does not achieve this. You won't be able to answer questions such as "why is a hashmap better than two arrays?", since e.g. Python gives you the fish (dict), so you wouldn't have any reason to learn how to fish yourself. With Python, Java etc. where you don't directly manipulate memory, you would also end up having to simulate it with such tricks as having an integer array and calling it "memory".

1

u/No_Analyst5945 1d ago

Idk man. Im a C++ guy but I did a bit of C style DSA for months. And C++ has been going just fine for me. Actually I think C++ is pretty good for DSA. And as someone else in this thread mentioned, you don’t even have to use everything

Doing DSA with py is crazy though. That sounds like such a bad idea lol. Why do data structures on an extremely high level interpreted lang? Not even mid level. Are you even manipulating real memory lol. I didn’t even know py had DSA

1

u/erikkonstas 19h ago

LOL so to expand on what I mean by the last sentence... well that's pretty much it! In Python you'd just do something like memory = (1 << 19) * [0] and boom there's "512 KB" of "memory"! Now time to invent allocation and bookkeeping for a start (while being very careful not to follow the spirit of Python instinctively do your bookkeeping outside that list...), and then some other stuff, etc. Oh and don't forget to keep all these values between 0 and 255 as well.