A Simplified Explanation about Data Structures

Karuna Sehgal
Karuna Sehgal
Published in
4 min readNov 14, 2017

Last week I mentioned that I wanted to create a series of blog posts about Algorithms, as it has been a hard concept for me to grasp as a programmer. Feel to check out the first blogpost about Algorithms, where I provide an introduction of what Algorithms are and an example of an algorithm.

This blog post I want to focus on Data Structures. I will explain what are Data Structures, how are Data Structures associated with Algorithms, and what are the types of Data Structures.

What are Data Structures?

Data Structures are a way to store data (so that way it can be used as desired). They are a way of collecting and organizing data in such a way that we can perform operations on these data in an effective way.

Data Structures & Algorithms

A great way to approach an algorithm is to think about the Data Structures that you know. We want to think about: what are their properties, and how can they be used to your advantage?

Types of Data Structures:

Array:

An array is a data structure that contains a group of elements. Typically these elements are all of the same data type, such as an integer or string. Arrays are commonly used in computer programs to organize data so that a related set of values can be easily sorted or searched.

Each element in an array has a number attached to it, called a numeric index, that allows you to access it. Arrays start at index zero and can be manipulated with various methods

Here is an image of what an array looks like:

Hash Table:

A hash table (also called a hash map, object or dictionary) is a data structure that pairs keys to values. A hash table uses a hash function to compute an index into an array of buckets or slots, from which the desired value can be found. The idea behind a hash function is to distribute the entries (key/value pairs) across an array of buckets.

Here is an image of a hash table:

I also like to think of a hash table like an object such as this one:

Linked List:

Linked lists are linear collections of data very much like an array, but instead of the data being arranged in one continuous block, each piece of data is linked to the next one in the chain using pointers coupled with the data.

Here is an image of a linear list:

Graph:

A graph is represented as a series of nodes and edges connecting those nodes. All we need to understand is the relationship between a given node pair, and then we store the edge connecting them. An edge is typically represented visually as a line and in words as a pair of nodes.

Here is an image of a graph:

Tree:

A tree is a data structure that is made up of a set of linked nodes, that can be used to represent a hierarchical relationship among data elements. In other words how it is connected by a series of references and has a root node.

Here is an image of a tree:

Queue:

A queue is a type of data structure, which help organize data in a particular order. A queue is a FIFO(First in First Out) data structure, which means that the element inserted first will also be removed first.

Here is a image of a queue:

Stack:

A stack is also another type of data structure, which help organize data in a particular order. A stack is a LIFO (Last in First Out) data structure. It is a simple data structure that allows adding and removing elements in a particular order. Every time an element is added, it goes on the top of the stack, the only element that can be removed is the element that was at the top of the stack, just like a pile of objects.

Here is an image of a stack:

Overall, Data Structures are really important to understand for a developer. Since we work on coding challenges on a daily basis, we can use Data Structures as approach to solve them. There are factors that need to be considered in which case it is important to use a particular data structure. This is where concepts such as optimization, time complexity, space complexity and Big O Notation come into place. I will cover those concepts in the next blog post.

--

--

Karuna Sehgal
Karuna Sehgal

Woman on a mission - to live the best life possible!!