Skip to content

A Quick and Easy Explanation to Understanding Data Structures & Algorithms

Image source: Markus Spiske on Unsplash
Image source: Markus Spiske

Learn to learn code faster, using techniques honed by years of study, neatly packaged into one book: How to Learn Code

These terms are the most important concepts to understand in programming. Data structures & Algorithms are not commonly talked about between developers. Though, I would say they encompass all of programming.

From the beginning of learning to code you learn these topics and how to use them. Developers usually learn how to use these concepts without even knowing the terms themselves.

But, why then do self-taught developers not talk about data structures & algorithms like its an everyday term? The answer is, they do.

What Are Data Structures

Variables are a form of data structure in all its forms and any manipulation of variables is, in essence, an algorithm. Let us take a look at two examples:

IntelliJ Screenshot: Example Data Structure 1
IntelliJ Screenshot: Example Data Structure 2

Here, the variable “int x” is a data structure. Anything written programmatically which uses memory is a data structure. It is a structure which stores data. In this case the structure is the “int” part, which is a built-in class to Java.

In example 2 you see the “Coordinate” class. This is also a data structure which holds the data “x, y & z”. But, do you hear developers saying, “yea I made a data structure to store x, y, & z”? No, you don’t.

Though data structures are foundational to programming, it would be the equivalent of calling salt a chemical compound. Reality is, chemical compounds make up all living things in this world, but do we actually say, “I am going to put chemical compounds onto my food”? No we don’t.

Now, I agree, this is a bit of an exaggerated example. But, that is the sentiment developers have about the terms “data structures & algorithms”.

What Are Algorithms?

As for algorithms, this is any code that changes a data structure. To create any type of algorithm you have to have a data structure. It is impossible to create an algorithm that doesn’t use at least 1 bit of memory. Otherwise, the code itself would not exist.

IntelliJ Screenshot: Example Algorithm

In the above image is an example algorithm. It is, “set x to 5, add 1 to x then print x”. Of course, this is a simple algorithm. However, the term is no different from an algorithm such as this one: 

LeetCode Screenshot: Problem 84 in Java

I will admit, when you get complicated, like in this second algorithm example, developers tend to use the word “algorithm”. But, they would not call the first example an algorithm, as that would be a bit lofty a phrase.

Anywho, I hope you learned something…

Happy coding!


Website from examples:

Data structure wiki:

Algorithm wiki:

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Posts

Learn to learn code faster, using techniques honed by years of study, neatly packaged into one book: How to Learn Code