Skip to content
Find me on GitHub Find on Twitter

What are Algorithms and Data Structures?

Hello there and welcome!!

Today we'll be discussing what are Data Structures and Algorithms (which we'll be referring to as DSA for short throughout the article). With that being said, let's get right into it!


What do you think programmers do?

The answer is way simpler than it is expected to be; they solve problems.

Now how do they concretely do that?

They try to store data in the most efficient way to manipulate it in logical and explicit steps to produce a desired output.

We will be elaborating on the last sentence

Data Structures:

They are different ways to store data in your computer (precisely, in RAM). In other words, they're nothing more than different ways to represent data.

Each representation has its own characteristics and implementations that differ from other Data Structures, it is the programmer's role to pick the right one (most optimal for storing, retrieval, searching etc. depending on the problem at hand)

Let's say you work in an IT team of some hotel and were asked to store all of the residents' information digitally.

You will first need to get acquainted with the type of data that needs to be stored, and in this example it would be: name, age, phone number, room number etc.

These information will not be magically stored on your computers, they need explicit representations that holds them; Data Structures.

Some examples of DS's are: arrays, linked lists, queues, stacks...

Here's an exhaustive list of them for the interested: Wikipedia

So how do I pick the right representation?

Before answering that, let us introduce Algorithms!


So far our scope was limited to computer science, but it will get broadened here!

This is the fun part! Many of us live by algorithms unknowingly!

Algorithms are logical and concise sequence of steps that solves a particular problem.

Throughout your programming journey, you will learn that everything boils down to making problem (which often is seemingly simple), even SIMPLER!!

Examples are endless here so we'll have fun one:

Say that as you're reading this article, someone knocks on the door.

What is the problem that was raised now? It is that the whoever is knocking must be answered! If you wish not to ignore that is haha

For you to answer the door you follow these steps:

  1. Stop whatever you are doing

  2. Stand up from whatever you may be sitting on

  3. Walk to the door till the distance between you and the door is an arm's reach

  4. Reach with your arm to the doorknob

  5. Rotate it

  6. Pull the door

  7. Speak with the person...

This sequence of steps is an example of an algorithm!

Many of you will find it plainly stupid, everyone knows that in order to answer the door you follow the last steps, and I agree as long as you're teaching a human to solve that problem; answering the door.

But if you were to teach the algorithm to a computer, that is another story.

You see, computers do not have intuition and they do not conduct operations on their own, it is the programmer that does the thinking for them, they just execute. So yes you could say that computers are REALLY dumb!

If you were to ask of the computer to answer the door, it will not understand it because you have not yet defined/explained how it could do so!

Thus, you will have to simplify the problem to a maximum (maybe even further more than I did in the last steps) for it to fully "understand".

Now let's return to our hotel example!

Remember my question?

How to pick the right data structure for a given problem?

You first need to get acquainted with the type of operations that need to be taken upon the data.

Let us reiterate, the given problem is storing the resident's information in the hotel.

What kind of operations are expected?

Adding residents, deleting ones that checked-out, modifying details about them in case of mistakes, verifying the data...

Based on that, the programmer picks the right Data Structure for storing the information.

With experience, you will get familiarized with that process and like anything else, it would become second nature so don't sweat on it!

Thank you for reading!

That was it ladies and gentlemen, I hope you enjoyed the article!

Follow me on Twitter for more!

Have a nice one!