Let’s talk about Data Structure and Algorithms.
Disclaimer !
Before you proceed!
Note that this series can be considered more of a reference than a full-on tutorial, I am no expert but in here I tried to explain the concepts from my point of view and from what I’ve learned. The reader can consider this as a referring point for a better understanding.
In my previous article we’ve seen a very generic and simple overview of what Algorithms are. In this article I want to talk about Data Structures.
Series Content:
DATA STRUCTURES
So what is a Data Structure? If we break this word into parts, we get DATA and STRUCTURE.
This is probably the most simple way of understanding what Data Structure is. It literally mans structuring or arranging the data in such a way that it’s efficient to handle in any scenario. Now if you read my previous article, I mentioned that the better or more optimised the algorithm the faster it is to get the result, and definitely the better. This actually has a constraint to it. Now, remember our previous example of making some really tasty instant noodles in the middle of the night? Let’s change the scenario and make it a little fun and interesting 😉.
Imagine you’re stuck in a virtual game, kinda like the one from Ready Player One. And to move to the next level of the game, you’re going to have to find a specific book, with a specific author and that has the key to the next level. Sounds easy right, but there’s a catch, you have, 20,000 books to search from and you have to look at each of the book to find the right one. Also, you have to do that within a specified time. The pressure just hit the roof top right?To go to the next level, you have to do it all in time.
Now let’s be honest, this does seem quite hard. But what if the books were arranged alphabetically based on their names? This just makes it a lot easier right? And further what if the books were further arranged sequentially according to their author’s names. This would help you so much to find somewhat the exact position where the book is.
If you consider all the books as your data and that special arrangement as a structure. You essentially have your DATA STRUCTURE. And what steps you’ll take to find the packet faster is your ALGORITHM.
Even in the real world, you have immense amount of data, and no matter how good your algorithm is, you need the data to be structured in such a way where you can efficiently find the data and manipulate it or deal with it according to the requirements of your problem. It’s like going to a library and looking for a book, if the books aren’t arranged according to a specific category, it’ll be excessively time consuming for anyone to find their desired book. And as I have mentioned before, every problem has a time constraint within which it needs to be solved. So a structured or organised data would always help in any kind of operation one would want to do on the data.
Most of the times, when you’re going for a solving a problem, the solution contains a mix of the use of both Data Structure and Algorithms together to reach the desired result.
So essentially Data Structure is needed so that we can arrange the data in such a way that allows us easy access to it in the memory of our system, and thus allows us to operate on it efficiently , and the Algorithm is needed to take the efficient steps to access that data, which we want to operate on.
Here are a few Data Structure that you may have heard of,
- Arrays
- Stacks
- Queues
- Graphs
- Trees
We’ll look at all of these and more. Hope this article helped you understand what data structure is and why it’s needed in the real world.