Should I learn Data Structures before Algorithms?

Data structures and algorithms are a key part of a Computer Scientist’s problem-solving toolkit.

Whether you’re learning these concepts for the first time or wish to ace an interview – the next logical question would be , “should I learn data structures before algorithms or vice versa?”

That’s what I’m here for – I’ll help you make a path for yourself, which you can follow to learn data structures and algorithms.


What Should I Learn First Data Structures or Algorithms?

Simply said, you should definitely be learning data structures before algorithms.

Why do I say that?

Well – data structures and algorithms go side by side. You’ll pick a problem and try to implement a solution to it. If you know a bit about algorithms, they’re nothing but a structured way to solve a problem.

But how would you implement a solution or an algorithm if you don’t know how to optimize it? That’s the data structures end of things – implementing optimized solutions to allow efficient access and modification to data.

So, if you’ve been wondering, what should I learn before algorithms? It’s data structures. Once you’ve done that, you’ll also be able to decide which data structure fits well with your choice of algorithms.


Which Language is Best for Data Structures?

Data structures aren’t dependent on languages. The concepts can be practiced in any language, but to make it more efficient, you should pick a high-level language that will show you the nitty-gritty details of data structures and algorithms.

Here’s a list of programming languages which you can learn and practice data structures on:

  1. Java
  2. C/C++
  3. Go
  4. Python

These languages have the most support for data structures and algorithms. Java and C might be a bit hard to maneuver through, but if you master your concepts in these, you won’t ever have an issue. It’s probably because these languages are slightly complicated and closer to systems development.

 In some cases, you might even find a library that has implementations for these concepts, and you can practice them right away. For example, Python has several libraries that you can import and implement your data structures. Though you should try to implement data structures on your own, too – to get a better idea as to how it all works. 

If you’re looking for resources to learn data structures, give Educative.io a look. They have descriptive courses on all concepts which you can use for learning. For example, here’s a course I found on Data Structures and Algorithms in Python – along with other language options as well.

In your quest to seeking answers to, should I learn data structures before algorithms, don’t forget – algorithms are just as important. Why? Let’s see!


Is it Necessary to Learn Algorithms?

One thing’s out of the way – you have to start with data structures in your quest to learn algorithms. Though there’s one other question that arises, “Is it necessary to learn algorithms?”

Source: https://www.wired.com/story/want-to-prove-your-business-is-fair-audit-your-algorithm/

Absolutely – it’s essential for a software developer or an engineer to understand several algorithms. They’re key to how programs and software behave and should be understood. How else would you be writing your own solutions to real-world problems?

Otherwise, you can try to understand the use-case of an algorithm and see how it will be used. Understanding that will help you pick the right algorithm for the right problem. Though that requires a bit of practice as well.

One other way you can look at this question is – the optimization of solutions. Let’s take it through an example – you’ve implemented a logging solution which generates thousands of logs for several operations. The logging feature has a complexity of O(n).

Now, what if this application goes from thousands to millions of operations? That’s very unoptimized and can be disastrous for the system itself. It’s times like these; you’d implement a proper data structure and algorithm to make the solution worthwhile.

So, is it necessary to learn algorithms? Yes, as it will help you write better code and understand engineering solutions better. Though you might have one other question from this, and I’ll bring it up next.


How hard is Data Structures and Algorithms?

Data structures and algorithms might seem hard from the get-go. It’s probably why some students don’t continue with their knowledge of the concepts. Though I’d like to emphasize here that it’s a myth and learning data structures and algorithms isn’t rocket science.

What you can do is to go through a structured approach, so you aren’t just learning anything any day. Let’s say; you start off with data structures first. Here’s a list of data structures that you should start with and then continue with more advanced ones:

  1. Arrays/Lists
  2. Stacks
  3. Queues
  4. Linked Lists
  5. Binary trees

If you’re looking for more resources on learning data structures online, give this article a look!

As for the advanced ones, you might want to go through these options:

  1. Hash-maps
  2. Graphs
  3. AVL/Self-balancing Trees
  4. Heap

Once done, you can go through some easy algorithms to get an idea of how software work. For example, here’s a list of some algorithms which are easy to understand and implement as well:

  1. Searching
  2. Sorting
  3. Dynamic Programming
  4. Greedy algorithms
  5. Divide and Conquer algorithms

Though the list is endless and understanding these basic algorithms will allow you to create your own. How do you do that? Practice, practice, and practice.

To help you understand the concepts and learn them through complex problems, I’d recommend going through AlgoExpert.io. They have explanations, complex problems, and support for several programming languages for you to go through.


Conclusion

That marks the end to our discussion on “should I learn data structures before algorithms.” Learning both of these concepts is essential to become a better developer and computer scientist. However, you should definitely be learning data structures before algorithms.

Why? It’ll help you pick the right data structure for your algorithm. Not only that, but you will know the strengths and weaknesses of each data structure for it to function with an algorithm.

I hope this article was helpful for you to get started on learning data structures and algorithms – the right way. If you’re looking for more advanced data structures interview questions, have a look at it here.

Leave a Reply

Your email address will not be published. Required fields are marked *