Over the last week, I studied seven commonly used data structures in great depth. The impetus for embarking on such a project was a resolution I made at the beginning of the year to train myself to be a better software engineer and write about things I learned in the process.

In the last 3 years since I first studied about them during my undergraduate studies, I felt no glimmer of temptation to study any one of them again; it wasn’t the complex concepts which kept me away, but their lack of usage in my day to day coding. Every data structure I’ve ever used was built into the language. And I’ve forgotten how they worked under the hood.

They were inescapable now. There are seven data structure in the series to be studied.

Let us go back to where it all began. Like every invention has a necessity, and having data structures also had one.

Say you’ve to find a specific book in an unorganized library. You’ve put in numerous hours in shuffling, organizing and searching for the book. The next day the librarian walks in, looks at the mess you’ve created and organizes the library in a different way.

Problem?

Just like you can organize books in a library in 100 different ways, you can structure data in 100 different ways. So, we need to find a way to organize our books(read: data) so that we can find our book(read: data) in a very efficient and fastest way.

Solution:

Luckily for us, some uber smart people have built great structures that have stood the test of time and help us solve our problem. All we need to know how they work and use them. We call them *data structures*. Accessing, inserting, deleting, finding, and sorting the data are some of the well-known operations that one can perform using data structures.

The first entry in the series ‘**Array’** leaves no need to have multiple data structures. And yet there will be so many more. I do not have the energy to describe why one data structure triumph over another one. But, I’ll be honest with you: it does matter knowing multiple data structures.

Still not convinced?

Let’s try to solve few operations with our beloved array. You want to find something in an array, just check every slot. Want to insert anything in middle? You can move every element to make room.

Easy-peasy, right?

The thing is “all of these are slow”. We want to find/sort/insert data efficiently and in the fastest possible way. An algorithm may want to perform these operations a million of times. If you can’t do them efficiently, many other algorithms are inefficient. As it turns out, you can do lots of things faster if you arrange the data differently.

You may think, “Ah, but what if they ask me trivia questions about which data structure is most important or rank them?”

At which point I must answer: At any rate, should that happen, just offer them this — the ranking of the data structures will be at least partially tied to problem context. And never ever forget to analyze time and space performance of the operations.

But if you want a ranking of learning different data structures, below is the list from most tolerable to “oh dear god”

- Array
- Stacks
- Queues
- Linked List
- Hash Tables
- Trees
- Graphs

You will need to keep the graph and trees somewhere near the end, for, I must confess: it is huge and deals with zillions of concepts and different algorithms.

Maps or arrays are easy. You’ll have a difficult time finding a real-world application that *doesn’t* use them. They are ubiquitous.

As you worked through the data structures series, you will realize one does not simply eat the chips from the Pringles tube, you pop them. The last chip to go in the tube is the first one to go in my stomach(LIFO). The pearl necklace you gifted your Valentine is nothing but a circular linked list with each pearl containing a bit of data. You just follow the string to the next pearl of data, and eventually, you end up at the beginning again.

Our Brain somehow makes the leap from being the most important organ to one of the world’s best example of a linked list. Consider the thinking process when you placed your car keys somewhere and couldn’t remember.Our brain follows association and tries to link one memory with another and so on and we finally recall the lost memory.

We are connected on Twitter. Thank you, Graphs. When a data structure called trees goes *against* nature’s tradition of having roots at the bottom, we accept it handily. Such is the magic of data structures. There is something ineffable about them — perhaps all our software are destined for greatness. We just haven’t picked the right data structure.

I will cover each of these individually in future articles. But let me give you answer to the question, Will your life be same after learning data structures?

Learning data structures is actually *Dante’s tenth circle of hell,* a truth which needs to be acknowledged universally.

Don’t tell me I didn’t warn you beforehand!

Stay tuned!

Resouces Used: