# Types of Data: A Developer's Roadmap to Data Structures and Beyond

By Avalith Editorial Team ♦ 1 min read

Every application needs to store information temporarily or permanently, for example, a person's data, measurements taken from a machine, details of sales made in a warehouse, etc. Usually, these types of data deal with a lot of sensitive information; this is why securing your data is key. For this, programming languages have provided data containers that allow storing information and processing it according to some criteria. These containers are called data structures.

Simply, a data structure is a container that stores data in a specific arrangement. This "arrangement" allows a data structure to be efficient in some operations and inefficient in others.

Based on different scenarios, data needs to be stored in a specific format. For this, different **types of data** will cover different storage needs.

## What are the types of data structures?

First, we must differentiate between static data structure and dynamic data structure.

Static data structures are those in which the memory size is defined before the program runs and cannot be changed during program execution, while a dynamic data structure is one in which the memory size can be changed during program execution.

Within the second group, there is another subdivision: linear or non-linear data structures.

## Linear Data Structures

Linear data structures are those in which elements occupy successive places in the structure, and each of them has a single successor and a single predecessor, i.e., their elements are located next to each other in a linear form.

There are three types of linear data structures:

Linked Lists

Stacks

Queues

## Linked List

A linked list, at first glance, may look similar to arrays but differs in memory allocation, internal structure, and how basic insertion and deletion operations are carried out.

A linked list is like a chain of nodes, where each node contains information such as data and a pointer to the next node in the chain. There is a pointer to the header, which points to the first element of the linked list, and if the list is empty, it simply points to null or nothing.

Linked lists are used to implement file systems, hash tables, and adjacency lists.

## Stacks

We all know the famous Undo option, which is present in almost every application. Have you ever wondered how it works? The idea: you store the previous states of your work in memory in a certain order, with the last one appearing first. This cannot be done using arrays alone. This is where the Stack comes in handy.

The stack is a special type of linear list that allows storing and retrieving data, with the mode of access to its elements being Last In, First Out (LIFO). How does it work? Through two basic operations: push, which puts an object on the stack, and its inverse operation, pop, which removes the last stacked element.

## Queues

Similar to the Stack, the Queue is another linear data structure that stores elements sequentially. The only significant difference between the Stack and the Queue is that instead of using the LIFO method, the Queue implements the First In, First Out (FIFO) method.

A perfect example of the Queue in real life: a line of people waiting at the ticket booth. If a new person arrives, they will line up at the end of the queue, not at the beginning, and the person at the beginning of the line will be the first to get a ticket and, therefore, the first to leave the line.

Therefore, there are also only two ways to manipulate a queue:

Insert an element at the end of the queue

Remove an element from the beginning of the queue

## Non-linear Data Structures

Non-linear data structures, also called multi-linked structures, are those in which each element can be linked to any other component. That is, each element can have several successors or several predecessors.

There are two types:

Trees

Graphs

## Trees

Trees consist of a non-linear structure used to represent data with a hierarchical relationship in which each element has a unique predecessor and can have several successors.

They are classified as general trees, where each element can have an unlimited number of sub-trees, and binary trees, which are a homogeneous, dynamic, and non-linear data structure where each element can have at most two nodes.

The most common structure is the binary tree, which has a maximum of two child nodes from the initial node (called root). A node can have parents, siblings, and children; nodes with at least one child are called internal nodes, and nodes without children are called external nodes.

Trees are similar to graphs, but the key difference is that a cycle cannot exist in a tree.

Trees are extensively used in AI and complex algorithms to provide an efficient storage mechanism for problem-solving.

## Graphs

Graphs are a mathematical structure formed by a set of points — a data structure — and a set of lines, each of which connects one point to another. Points are called nodes or vertices of the graph, and the lines are called edges or arcs.

Social networks use graphs to handle a large amount of interconnected data they receive at every moment. The most famous example, the GraphQL query language, was created by Facebook to use graphs to access and relate data.

Another famous use for graphs is the navigation system of map/GPS applications and the shortest path algorithm to define routes.

As you may have noticed, each structure could take hours and hours of study for a complete understanding of the paradigm. At Avalith, we have a team of experts ready to help you save time by covering all your needs. Get in touch with us and learn more!

The study of data structures, along with their algorithms, is an essential part of programming fundamentals. It is interesting to combine the study of these topics with practice to gradually add more knowledge.

Data structures in programming are a key aspect of knowing if you are starting in this world. They allow us to improve our code and technical skills and ultimately solve complex problems efficiently, optimizing resources, which is very useful for IoT and environments working with Big Data.