Follow us on
Welcome Guest! You are here: Home » Science & Technology
What should be the first thing to learn: Algorithms or Data Structures?

Tuesday September 11, 2018 11:30 PM, Zohair M Safwan, ummid.com

Data Structure and Algorithm

If we try to look at things in the simplest ways, we always have some form of data, and we have some operations that we perform on that data. In the world of mathematics, we work on 'operands,' and we have a set of 'operators' to do that with. Similarly, we have data, and we must have a way to process that data, which is done through algorithms.

Data structures are collections of data with certain features, along with some functions and operations that can be performed upon them. This includes organizing the structures and efficient management and storage and having proper access and modification. Algorithms, on the other hand, is a set of rules or protocols that are to be applied to a set of data to solve a problem. These algorithms can be used for calculations or data processing and other automated tasks. Thus, these data structures and algorithms are thoroughly linked to each other. It already becomes clear from the definitions themselves which one should come first.

What should you be doing?

Algorithms are supposed to working on the data which should have to be stored somewhere physically on the hard drive. This provides a vague idea itself that you might need to know about data structures first so that you learn how to handle the data and store it properly before applying some operation on it. The two are intertwined, and before the data can be manipulated with the help of algorithms, we need the data to manipulate. Storing the data and retrieving it in useable and efficient formats is one of the most important factors. Many algorithms would require a proper data structure at its heart that it could be intelligently working on.

Learning Data Structures First

The more that is known about the data structures and their strengths and weaknesses, the more easily you would grasp how algorithms function. Some of the languages are centralized around the data, while there are those who stress more on the functions. There are entire programming paradigms that talk about these. While in the structural and procedural paradigms, you are required to consider the algorithms at play, in object-oriented programming languages, you are required to emphasize on the data that you are required to work on. C programming language is great to get your hand dirty on data structures and algorithm concepts. You can learn C from the best C tutorials recommended by the programming community on Hackr.io.

Learning about algorithms envelops the whole concept of learning data structures. The entire concept of data structures acts like a building block on which the algorithms are to be based. If you look at it in that sense, you must know about the structures properly, their ups and downs before they can be applied in a particular scenario. In this way, you would be able to choose which structure would be the most effective in a particular situation and then use the algorithm that suits the needs.

For instance, if you at some point need a structure where you would not be making many changes, but you need to access the data constantly in constant time, you would be thinking arrays. But if you would need to make some changes in the structure constantly, linked lists or other data structures start coming into the equation. Now once you the exact data structure that you would be using in this particular problem, you would be designing the algorithms for that particular case. This, as you can see, would in no way be possible if you start learning about algorithms first without knowing much about data structures anyway. So the entire goal is to move forward in a way that you can optimize your results in the best way possible. This would not be feasible if you skip the stepping stones.

The purpose of learning data structures is to allow certain data that we know follow certain criteria to be retrieved a lot faster than scanning the entire thing. Several algorithms might need the smallest value in a collection at any point in time. Remembering the values in each variable is not an option as the elements are being added and deleted from the collection over time. The collection could simply be stored in an unsorted array and scanned every time we need the smallest element. The process would take a long time as you would need to scan N elements each time. This is surely not a possibility, and there needs to be some tweaking. Not only that, since random insertions and deletions are being made, the array would not be a good choice from that point of view. This means we could benefit if we had some other structure that allows you to do that.

But what if we're using a combination of a Binary Search Tree and AVL Tree to store the elements? The Binary Search Tree would ensure that you find the smallest element at the leftmost leaf node, and the AVL Tree structure would not allow the structure to become too skewed to ensure that the time taken in insertions, deletions and traversal is at a minimum. All of this strengthens the belief that learning about these data structures would put you in ease while working with these algorithms.

But, does it mean that you should never be learning algorithms before you know the entire concept of data structures? That is not all true. Learning algorithms first can sometimes have their upsides as well. Let us look at when you should be learning algorithms first.

Learning Algorithms First

Learning about algorithms first would only make sense if the fundamental idea behind solving the problem is to devise certain algorithms that can be applied to a given problem. More often than not, you would be given a problem, and you would find that it would not make much of a difference which data structure you are using (considering you do not use some structure deliberately that makes the problem difficult). Also, while writing most codes, the stress is more on what path you follow than on how you store the data.

Though this means that you would be better suited if you go with data structures first, learning algorithms first won't do any harm either.

For all the latest News, Opinions and Views, download ummid.com App

Select Langauge To Read in Urdu, Hindi, Marathi or Arabic

Share this page
 Post Comments
Note: By posting your comments here you agree to the terms and conditions of www.ummid.com