Understanding Data Structure for the Cat Lovers
“ In computer science, a data structure is a data organization, management, and storage format that enables efficient access and modification. More precisely, a data structure is a collection of data values, the relationships among them, and the functions or operations that can be applied to the data.”
If you have minimal computer science background like me. Reading this will might as well be learning an alien language.
So here is how I understand what Data Structure is.
It might be a silly example, but you will later see why I use this as an example
Let says you host a party for your cat, and each person who would come to your party would bring a cat with a name tag on them. So let’s use an example with five cats
Popo, Momo, Mochi, Lychee, and Chonky

These five cats now in computer science term is considered to be data, and the way we arrange them in our party room is considered to be data structured.

Here we thought of a way to smartly store all of our cats in a box. We create a long box with many boxes inside, having the same size of 5x5 inches. These boxes are arranged beforehand into an ordered way so that if you say box number 1, you know exactly where to find the box. So at every time, someone comes to the party, they will put their cat into one of these numbered boxes. Surprise! What you just did is recreating a data structure called Array.
Here is another idea you have. Instead of a boring box of boxes, you fancy it up with a cat train!

Now you create a train of individual boxes that are connected with strings. So Popo would be connected to Momo with a string, and Momo would be connected to Mochi with a string and so on. This type of data structure is called Linked List.
So the natural question then is: “Which cat arrangement/data structure is the best ?”
As all things in life, the answer is: It depends on the situation.
Each data structure has its advantages and disadvantages.
Scenario 1: Let say you are one of the cat owner, and you are looking for your cat Chonky, which happened to be the 90th one to join the party.
Given the Array data structure, because all boxes are in 1 box and all have the same length of 5 inches, you can walk 5x90 = 450 inches of boxes, and you would be able to find Chonky.
Whereas Linked List, because the strings that connected the boxes stretches and not in the same formation, some of the boxes ended up in different rooms, and Chonky can now be either in the kitchen or the roof.
In this case, Array come out the winner data structure for finding the right cat.
Scenario 2: Let say you expect 100 cats to show up at the party. However, the party became so popular and known that five celebrities’ cats show up! How will you then manage to squeeze them into the house?
Given the Linked List data structure, all you have to do is attaching five more boxes with strings into the train, and voila, five new celebrities can join in.
In the case of Array, the big box can only contain 100 small boxes in it. So to fit five more spots in the structure, you will either need to create a separate box with five boxes or put all the existing cats in the box out, create a new box with 200 spots in it this time, then fit the cats back into the new box in the original order, then add the new celebrity cats in.
Consequentially, if the unexpected guests vary between 5–1000 cats, Linked List become much convenient to use because it is way easier to resize than Array.
Linked List comes out as the winner.
As a software developer, it is essential to understand data structure and how we can use them to best fit into different situations. Understanding data structure is the first step to efficiently create an application, whereas understanding which algorithm will be the 2nd step. For more in-depth knowledge of Algorithm, I highly recommend checking out Eric Kim and Daniela Sandoval very meme-y and easy to understand post about Algorithm and the Big O notation
