If you’re into programming, most likely you’ve heard of Data Structures. But, as a web developer, we often overlook it. We can build a web without learning it too deeply. So, what exactly is a Data Structure?
Data structure is a specific format we use to store, manage and organize our data so that it can be used efficiently.
So, I’ll introduce you to the basic overview of data structures and why is it important.
- Arrays are collections of items with index-value pairs with indexes starting from 0.
- Objects are collections of items with key-value pairs.
- Stacks are lists that behave like books. Imagine you have books stacked over. To add an item, you put it at the top and to remove an item, you take it from the top. That principle is called LIFO (Last In First Out)
- Queues are lists that behave like people queueing at a store. The ones that come first are first served and it is called FIFO (First In First Out). It is the opposite of Stacks.
- Linked Lists are lists in which their items point to each other. So, to access a certain item, you have to go through the first item until you get to that item. All the items are connected.
- Trees are lists that in which their items or nodes have parent/child relationship. One item (parent) can point to multiple items (children) and keep going on until they form a tree structure.
- Graphs are structures that can connect with each other in an unstructured way.
Why Is It Important?
Choosing the right data structure can give a great performance boost to an algorithm. But, using the right data structure from the start is better obviously.
Using certain data structures can be faster depending on the case. You wouldn’t want to cook with a screwdriver right? Choosing the right tool for the right job is an important part in programming.
Putting the right data structure into a slow program can work the same wonders as transplanting fresh parts into a sick patient.Skiena
Also check out an inseparable topic from Data Structures in my other post, What is Algorithm And Why is It Important?