DEV Community

Cover image for Data Structures vs. Algorithms?
Ahmed Wafik
Ahmed Wafik

Posted on

Data Structures vs. Algorithms?

If you are a fresh or junior Software engineer, you probably heard a lot about data structures and algorithms. Everyone tells you about their importance or how valuable to learn them. You hear about them together, and sometimes you ask yourself, are they one thing, or do they most come together? So what is data structures and algorithms, or what are data structures vs. algorithms?

Think with me

If you search on Wikipedia about data structures, you will find:

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, their relationships, and the functions or operations that can be applied to the data.

If you search on Wikipedia about Algorithms, you will find:

In mathematics and computer science, an algorithm is a finite sequence of well-defined instructions, typically used to solve a class of specific problems or to perform a computation.

So that is what the book says about data structures and algorithms, but why do you hear about both of them as a package? What value do you have from learning them?

Good learning of data structures and algorithms will help you solve more problems easier. In a world driven by big data and microservices technology, a good understanding of this science is the base you can build on it to develop high-quality software.

Coding

To understand more, let me tell you a story. This story is about John. He is a chef in one of the elite restaurants. He is famous for his low-time cooking and high-quality food. We interviewed him to know what is his secrets.

Q: Hello John, can you tell us what is your secrets?
A: hahaha, I don’t have any secrets, I studied data structures and algorithms science in high school, and they were one of my favorite subjects, so when I started working as a chef, I used them in my daily work that my (secret).

Q: No, explain to me How?
A: data structures and algorithms science is not only applied in computer science. It is a way of thinking and mindset that can help you solve any problems, like divide and conquer algorithms. People use it in real-life problems, so machines use it in software issues.

Q: ok, let me understand more from you. How do Algorithms help you in cocking?
A: ok, for me, Algorithm is the set of steps I take to optimize the process of cooking so for example, I can go to the fridge to get one ingredient at a time, which is terrible and waste more time, or I can go one time or two and bring bulk ingredients at a time and save more time. Decisions like this are my Algorithm to cook faster.

Q: ok, that’s clever of you, but what about data structures?
A: the ingredient for my meal is like the data for the computer process, so I need to store my ingredients in a structure that makes things easier when cocking, like a computer program stores the data in a particular data structure.
So, for example, I can store onions in a net because their shape is circular to retrieve them faster. That can also be applied for tomato, but it has a different body for cucumber, so I can store it on a flat surface without being worried about it rolling off. That is exactly what you do when you write a program. You choose the data structures that suit your data type, and your problem type is an insertion problem or retrieving problem, for example.

Q: thank you for your time, John.
A: That was my pleasure.

Conclusion

Data Structure and algorithms are science that you can apply with any programming language in any software field and even in real-life problems.
A good understanding of this science will help you boost your code quality and build more efficient applications that can handle more load with good performance.
Thanks for reading ❤️❤️

Feel free to reach out on Linkedin


Resources

Data Structures

Algorithms

Top comments (0)