ivangeorgiev.dev

Introduction to data structures

Learn about data structures in an intuitive way

November 5th, 2024 2 minute read

Data structures are item containers. We use them in our daily lives all the time. They allow us to store items and retrieve them at a latter time.

Let's take our pockets and wallets for example.
To store something into our pocket, we simply insert the item inside the pocket.
To retrieve something from our pocket, we need to insert our hand inside the pocket, fiddle around and recognize the desired item by touch. If we don't succeed this way (e.g. there are many items), we have to take every item out of the pocket and recognize the desired item by sight.
We can conclude that a pocket is very convenient for storing items, but it can be a slight challenge to retrieve an item.

Over to the wallet - to insert something into our wallet, we have to open the wallet, find the right compartment and insert the item.
To retrieve something from our wallet, we need to open the wallet, find the right compartment and retrieve the desired item. If we don't know the right compartment (e.g. it's a new wallet) we need check every compartment.
We can conclude that a wallet offers similar convenience for storing and retrieving items.

Let's compare the pocket and wallet item containers.

We can conclude that both item containers can store and retrieve items. Depending on the needs, one or the other can be a better choice.

It's the same with data structures in programming. There are different data structures that store and retrieve data. They structure the data in different ways and are suitable for different objectives.

The next articles will cover different data structures. We will see how they store and retrieve data and what kind of objectives they are suitable for.

If you enjoy my articles, please consider supporting me.