Why Data Structures Matters : A Beginner-friendly Guide

Hiren GajjarHiren Gajjar
5 min read

How Data Structures are the Backbone of Programming & Computing in General?

The fundamental aim of programming and computing in general is to do more with less. Less in terms of resources, time — or in other words, higher efficiency and performance. Just like in life, we have different tools to perform different tasks; although there are tools that can serve multiple purposes, only an expert knows which tool to use and when. For example, we can cut a tree with a knife, but we do not have to. We have many modern tools that are faster, safer, and more effective.
Similarly, most programming languages offer various ways to store, organize, manage, and when needed, perform some kind of operation on data. And we call them Data Structures.
Of course, this is a very naive definition, and we can go into technical jargon. But the aim of this writing is to help the reader get familiar with the basics of Data Structures without getting bored.

So, strengthen your seatbelt for a roller coaster ride and let’s gooooo!!


And what type of Data Structures do we have in general?

If you immediately have the question after reading the above paragraph — “what type of data structures do we have then?” — Congratulations. You’re on the right path. Here’s what we have:

  • Arrays

  • Queues

  • Graphs

  • Trees (Yes!)

  • Stacks

  • Linked List

  • And others.

As we discussed above, just like each tool, every data structure has a specific nature and carries certain properties that make most of them unique in a way to perform specific tasks. For instance, how often do we find ourselves waiting in a queue for a movie ticket?
Similarly, computers have a concept of Queues that stores data in a very specific manner.

Queues

Just like the person who comes first to the ticket window will be served first, and then the person after, and so on and so forth. The catch here is that there can be multiple windows and multiple queues (ignoring the fact that nobody in today’s world waits in queues, as we use apps and websites for the same), but you got the point.

290+ Ticket Counter Queue Stock Illustrations, Royalty-Free Vector Graphics  & Clip Art - iStock

The Queue follows the FIFO principleFirst In, First Out. By default, the new element (next person in line) is added at the last, and whoever is the first at any given point of time will be executed first (will get the ticket). There are certain things we can do in queues in computers like: add, remove, check if the queue is empty or not, what is the size of the queue, etc.

As we can conclude here, a queue is a good way to store, manage, and organize data. But imagine we have a million people in a queue? Because such use cases are very normal for an average computer.
At that point, we raise questions of efficiency. As mentioned in the introduction, we can use many tools to do the same task, but it is always the right tool that gives the best output.


So how to identify what is the right Data Structure for each task?

The answer is: we do not know!!
Yes. As a beginner, here we have a brief of data structures. In computer science, the subject called Data Structures and Algorithms (DSA) is very popular to climb the ladder of becoming a top-notch performer (mostly as a programmer). So our next goal should be to understand each and every data structure, their properties, how each works, and then start solving real-life problems. And just like all great things, it takes time and many iterations. But after solving certain problems, it becomes natural to know what to use and when.


How is the performance of a data structure measured?

There are mainly two matrices that matter the most. As we talked a lot about efficiency above, but how do we measure who is better over others? The answer is Space & Time. Don’t worry — we are not talking about general relativity here 😄.

Every data structure is written in code that the computer will translate into binary (know how and why here) and then we measure:

  • what space it is occupying in memory

  • and how long it takes to complete the given task.

The technical jargon for the same are: Time Complexity and Space Complexity.


Ending Notes

  • There are tools for each task and each tool can be used for another, but the important thing is to know when to use what.

  • Similarly, there are many data structures — many sound the same, some are just variations of others, a few have more to offer, and others have less. The point is to perform tasks in the shortest time with the lowest space possible.

  • There are problems that simply can’t be solved using a single tool (in programming, data structures).
    At that time, we may use a collaboration of more than one tool (in programming, sometimes that is also called Algorithms).

  • The bottom line is:
    More practice, over and over again, gives broader and deeper understanding of Data Structures and their uses.

  • Time Complexity and Space Complexity are the fundamental metrics to keep in mind.

That is all from my side. If you agree or disagree (hoping for some counter arguments!!) with my perspective; give it a comment and help me write better.

Happy Reading.

1
Subscribe to my newsletter

Read articles from Hiren Gajjar directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Hiren Gajjar
Hiren Gajjar