# What are Data Structures

We have already said in the *order of learning* that:

Data Structures are a way of organising data.

**NOTE**: In most cases, the definition of a term is always embedded in the name itself. Oftentimes you just have to break the words into smaller parts and the meaning becomes obvious.

Data Structures stand at the heart of algorithms. Why? Because algorithms are designed to work with data. They take data as input and return data as output. However, if the data was just thrown as random bytes and there were no structure to it, then it becomes nearly impossible to work with data. The algorithm wouldn’t know how to read data or how to write it.

## The importance of Data Structures

Think of a sorting algorithm. It takes a list of numbers as input and gives out a list of sorted numbers as output. For the algorithm to work, it should know how to read the numbers. Normally they are provided as an array. An array is a sequential list of same type of data (in this case, numbers). An array of numbers can look like this:

```
10,34,29,74,29,75,912,8445,23,3,8
```

which is actually one number after another in the computer memory. However, if the rules were not that strict and there were random blank spaces between numbers, it would look like:

```
10,34, , , ,29,74,29,75, ,912,8445, ,23, , ,3, ,8
```

Now it becomes difficult to read the numbers. You might think - one can easily filter out spaces from between the numbers or ignore them in the algorithm. There are two problems with that:

- The algorithm becomes much more difficult to build because now you have to write a check (or test) for every single step of the algorithm to ignore the blank spaces where data is being accessed from the list.
- In computer memory, there are no blank spaces. The closest you can come to a blank space in computer memory is a byte filled with all 0s, which actually has the value of numeric
`0`

. So the algorithm would read the list with spaces like:`10,34,0,0,0,29,74,29,75,0,912,8445,0,23,0,0,3,0,8`

See the problem? If this list were to be sorted in increasing order, it would produce this result:

`0,0,0,0,0,0,0,0,3,8,10,23,29,29,34,74,75,912,8445`

What we wanted was this:

`3,8,10,23,29,29,34,74,75,912,8445`

Without a proper data structure, not only the length but also the content of the result comes out different. This is when we altered the expected data structure in a very small way. Some of the more advanced algorithms would produce almost random-looking results if the input data was not structured properly.

We hope we have established why Data Structures are important.

## The different Data Structures

There are numerous ways in which you can organize data. So the list of Data Structures is pretty exhaustive. Thus, we are going to learn about only the most useful ones. For example, there is a data structure known as *Q-Tree* but we are not going to learn about it because that is an advanced Data Structure. Once you have mastered the basic Data Structures and algorithms built for them, we can learn about the advanced ones later. For this course, we are going to start with:

- Arrays
- Stacks
- Queues
- Double-ended Queues
- Circular Queues
- Linked Lists
- Doubly Linked lists
- Hash Tables (or Dictionaries)
- Matrices (Two-Dimensional Arrays)
- Graphs
- Trees (multiple types of trees)
- Heaps
- Sets

It might look like a long list at first. Just begin and you will start liking them. They are pretty easy to understand and we’ll keep them interesting.