Rediscovering Data Structures from Childhood
As kids, we unknowingly used data structures all the time. Now, let's rediscover these hidden gems from our childhood and learn how to explain them to a 5-year-old. Discover these fundamental tools in a fun and engaging way with Brilliant.org.
![Author profile image](https://pbs.twimg.com/profile_images/1617044903636123650/pYUcGGOu_normal.jpg)
Francesco
· Developer Advocate at @dailydotdev · Docker Captain · Public Speaker · Building a 1 Million Community 23% · All the links ➞ https://t.co/2DLpQ5cNoa
![Header media for article](https://pbs.twimg.com/media/FtWXqm1WwAEXPOe.png)
-
🧸 As kids, we unknowingly used data structures all the time.
— Francesco (@FrancescoCiull4) April 10, 2023
Now, let's rediscover these hidden gems from our childhood:
📚 Arrays
🔗 Lists
🥞 Stacks
🎢 Queues
🌳 Trees
🗺️ Graphs
Here's how I'd explain them to a 5-year-old in a single tweet each.
A thread: -
Learning data structures doesn't have to be boring! Discover these fundamental tools in a fun and engaging way with @brilliantorg.
— Francesco (@FrancescoCiull4) April 10, 2023
Their courses break down complex concepts into easy-to-understand building blocks.
Try them out for yourself at https://t.co/xaHSNNArQQ -
📚Array
— Francesco (@FrancescoCiull4) April 10, 2023
An array is like a long shelf with several compartments to put things in a specific order.
You can quickly find the item you want if you know its position on the shelf. -
💡Interesting fact:
— Francesco (@FrancescoCiull4) April 10, 2023
Arrays can hold more than just numbers or words! They can store other arrays, called multidimensional arrays. A 2D array can be used to create a grid-like structure, also called Matrix. -
🔗 List
— Francesco (@FrancescoCiull4) April 10, 2023
A list is similar to an array, but it's like a magic shelf that can grow or shrink depending on how many items you want to store.
You can add or remove items quickly, but finding a specific item might take longer. -
About linked lists, if you want to know more, there is a very understandable lesson in the "Data Structures course" on @brilliantorghttps://t.co/xaHSNNArQQ pic.twitter.com/aoZxtOg20v
— Francesco (@FrancescoCiull4) April 10, 2023 -
Imagine a stack of pancakes.
— Francesco (@FrancescoCiull4) April 10, 2023
With a stack data structure, you can only add a new pancake on top or take the top one off, just like when you eat pancakes, you start from the top.
This is called LIFO (Last-In-First-Out). -
💡Stacks can be used to perform algorithms such as Depth-First Search (DFS) of tree/graph data structures.
— Francesco (@FrancescoCiull4) April 10, 2023
By keeping track of visited nodes using a stack, we can explore the structure in a way that prioritizes going deeper into the structure before exploring other branches. -
🎢Queue
— Francesco (@FrancescoCiull4) April 10, 2023
A queue is like a line of people waiting to get on a ride at an amusement park.
The person who arrives first goes on the ride first, and new people join the line at the end.
This is called FIFO (First-In-First-Out or FIFO). -
💡 Another use of the queue is in simulating a print spooler to manage multiple print requests from different users.
— Francesco (@FrancescoCiull4) April 10, 2023
Each print request is added to the queue & processed in a first-come, first-served manner: each print job is processed in the order it was received. -
🌳 Tree
— Francesco (@FrancescoCiull4) April 10, 2023
A tree is like a family tree, with a root at the top & branches below.
Each item (except the root) has a parent & may have children.
Organizes info for easy searching! -
💡Interesting fact about trees:
— Francesco (@FrancescoCiull4) April 10, 2023
Did you know that adding extra edges between nodes can turn a tree into a graph?
This process is called "grafting".
It can be helpful in graph algorithms that require a tree-like structure.
But what are graphs? -
🗺️Graphs
— Francesco (@FrancescoCiull4) April 10, 2023
Graphs are like maps that show how things are connected. (even a virtual one is a good example!)
For example, on a map of your town, a graph can help you see how your house, the park, the grocery store, and your friend's house are all connected. -
That's all, folks!
— Francesco (@FrancescoCiull4) April 10, 2023
We've explored some of the most fascinating and useful data structures, from arrays to graphs.
This was a good point to start, but definitely not the end! -
If you want to know more about algorithm complexity, you can check this excellent course by @brilliantorghttps://t.co/xaHSNNAZGo pic.twitter.com/C3QOrsYFcU
— Francesco (@FrancescoCiull4) April 10, 2023 -
Learning Data Structures can be crucial for your career.
— Francesco (@FrancescoCiull4) April 10, 2023
I'm partnering with @brilliantorg because their courses are really on another level (when you'll see one, you will understand)https://t.co/xaHSNNArQQ pic.twitter.com/cHUWQSMQqt