When you hear the word “Data Structures”, you probably respond in one of three ways:
- You immediately know what other person is talking about because you studied computer science and you belong to the Know-It-All group.
- You know it is one of the Recruiter’s Favorite Interview questions but you really aren’t sure what the word means and how it is useful.
- You run and hide in fear because everything you know about them reminds of complicated codes and calculus nightmares.
But, very recently, I figured there is one more way to respond to this word. That is “I know about them but I can’t recollect how they work under the hood.”
If you nodded your head to any of the above responses, this series is for YOU.
Last month, I revised seven data structures in a week. I decided to undertake this journey when I found myself in the newest respondent category. I remembered about their existence but completely forgotten how they worked under the hood. My world was filled with blindly using the built-in data structures in the programming languages I work. But the resolution I took to polish my software engineering skills had sealed my fate and I was running out of excuses.
There are seven Data Structures in this Data Structures Tutorial series now.
I tried to sort through these pillars of programming and build myself a strong base which gets etched in my memory forever.
With this series, there will be no more of I-Knew-Them-All-But-I-Forgot.
When you start learning about data structures, you’ll often find yourself surrounded by Mathematical Proofs and Ideas and terms like Jagged Arrays and Binary Search Trees. They will sound completely alien from anything we’d ever do as a human being but trust me they are not.
Humans think in Data structures:
We, as humans, are wired to think in Data Structures. We just don’t know it yet. Like I didn’t. We just don’t use term data structures to describe or while when we use them. Let us take a real-life example to see how humans think in terms of Data Structures.
Whenever you get a task to go out for shopping, what do you do? You start writing in order, on a piece of paper, the items that you have to buy. Unknowingly you have created a list.
Still not convinced?
Let’s say I asked you to search a word ‘deranged’ in a dictionary. Quite an easy task to do as the words in the dictionary are sorted alphabetically and you can easily find the word you’re looking for. This kind of arrangement is called Sorted Lists in Data Structures, see how we have Data Structures incorporated in our daily lives.
Now, imagine a scenario, where the words in the dictionary were written randomly or in an unsorted fashion?
Sure, we can sit whole day and try to find word ‘deranged’ in our messy dictionary but we live in an age where time always runs in our mind. We want things which are fast, easier to maintain and highly efficient.
Data Structures in Programming:
Similarly, in our programming world, we’ve some ready-made structures which we can use to organize our data efficiently. They are known as Data Structures. Accessing, Inserting, Deleting, Finding, and Sorting the data are some of the well-known operations performed using data structures.
Below is the list of different data structures we will be covering in our series:
- Linked List
- Hash Tables
The very first entry in our Data Structure Series, ‘Array’ is a beast in itself. And yet we’ve like seven data structure in the series. I plan to write an entire series to describe them to you individually in the future. But, for now, it does matter knowing all seven of them in great depth.
I know, you may think, “Seven is a big number. Can’t you just write about the most important data structures?” To answer your question let us understand the importance of Data Structures
Importance of Data Structures
To understand why so many structures need to be studied, let us try to solve a few operations with our first entry, Array. Let us say you want to find an element in it. To do so we have to keep checking in every element of the array till we find the element we are looking for. If the element is located at the end of the Array we will end up iterating over all the elements to reach the target element. That will be a time-consuming process if we have lots of elements.
Similarly, if we want to insert a new entry in the Array. We will need to first move all the elements on the right to one position to the right. That way it will create space for the new element that needs to be inserted. This will make the insertion operation slow. Time is precious and our operations shouldn’t be slow. An Algorithm (a bunch of steps to complete a task) may perform these operations many times and if one of our Data Structure operations is inefficient, so is our algorithm.
An important point to note here is that you can do lots of things faster if you arrange the data differently.
Yes, a different arrangement of data can increase our program efficiency.
As we will learn in the coming tutorials, all the data structures mentioned above arrange data in different ways so that they can provide efficient operations on them.
With this much of understanding let us look at some questions that we should address before we move on to individual Data Structures
Question: Can we just learn the most important Data Structures used throughout the Software Industry?
You can’t, right? Every Data Structure that we will learn will have its own Positives and Negatives. Each Data Structure shines in different use-cases. Just as we can’t rank different use-cases, we can’t rank data structures either. Every data structure needs to be evaluated in the context of use. And its performance for that use-case lets us choose the right Data Structure for that situation.
As we work our way through the series, we will see there lies a division between these structures too. They are divided on basis of how data is constructed and traversed, briefly into two types:
- Linear Data Structures
- Non-Linear Data Structures
Congrats you’ve made to the bottom of this post-stack. There are many technical posts about data structures you could have read instead. I am very grateful you made this choice.
I thought I’d take a minute to answer some questions about what this series is going to be like:
What will be covered in this series?
I guess the secret is out already. Still, I’ll be writing about seven different type of data structures and how our real world is filled with those structures. Sometimes the post could be an essay or story or an analogy so deep which will change the way you look at some real life stuff.
Using the analogies we will explore a given Data structure. We will learn what is the usage of the data structure and when that data structure should be used. We will also measure the performance of the Data structure using Space and Time complexity of different operations on the Data Structure.
Will this series help me get a professional level understanding of Data Structures?
Yes, this series will be really helpful for you to understand Data Structures at a level that you can wisely use them in your professional work. You will be able to make right objective choice of using a give data structure. And will be able to impress your peers.
Why is this series different from other famous books on Data Structures?
This series will not only talk about factual information about the Data structures but will also use real-time examples to understand it. I myself went through this process of learning it from basic to details, I will target the exact questions that you will have in your mind which will enable you to understand this topic properly. The series will be supplemented with code and examples which will be to the point.
About Author :
My name is Shilpa Jain and I’m a software engineer working commercially with web domain since 2014, currently residing in Mumbai, India. I blog about things I learn(sometimes) daily for posterity and educational purposes.