**Data Structures** implies the data means information of any kind and the structure means an arrangement that is an arrangement of data.

Let us start with an introduction to data structures and algorithm.

## Definition of Data Structure

**What is Data Structures?:** Unsequenced sentences or information can be arranged in a particular format is known as a data structure.

The definition of Data structure of states that the data is stored in a particular format. The example of data structures is Array, Stack, Queue, Linked list, Tree and Graph, etc.

Data structures can be used in almost every aspect of computer science such as in Operating system, compilers designs, etc. Using Data structure will increase performance as we store data in an efficient way.

### Why do we use data structures?

1. Using data structure we can access the information stored on disk very efficiently.

2. Easy to access data as well as for processing the data.

3. It is a secure way to store the data.

4. Better management of data.

Now we know what a data structure is and why it is used now we will see the different type of data structures.

### Classification of data structure

As a data structure arranges the data in a particular format there are many data structure to implement that. These data structures are divided into the two main types

### Types of Data Structure

There are two types of data structures: Linear and Non-Linear data structures

#### Linear Data Structures

If all elements are arranged in linear order then it is referred to as Linear Data Structures. All elements are stored in the same format that is elements are stored in Non-hierarchical way.

**Types of Linear Data Structures are given below:**

1. Array

2. Stack

3. Queue

4. Linked list

In this type of data structure, the data is stored in a linear way. And the data is traversed in a sequential way that is we can access only one element. Example: Array, Linked list, Stack, Queue.

##### 1. Array

An array is a linear type of data structure. It is a collection of elements of similar type. An array can store any type of data such as int, float, double, etc. The name of each element of an array is the same but each one hold different value and each element in an array is accessed using array index. As it is a linear it’s sequential access as well. The arrangement of data in an array is in systematic order.

**Example**: int array [5];

The individual elements of array is, array [0], array [1], array [2], array [3], array [4].

##### 2. Stack

The stack is also a linear type of data structure in which insertion and deletions are allowed only at one end, called top. It works on LIFO (Last In First Out) Manner. The elements from the stack are retrieved from the top. Stack works according to real-time stack.

**Example**: Piles of plates

##### 3. Queue

The queue is also a linear type of data structure in which insertions are done from one end called Rear end and deletions are done from another end, called Front End. A queue is opened from both ends. It works on FIFO (First In First Out) Manner.

**Example**: Ticket Counter

##### 4. Linked list

It is also a linear type of data structure. Data is stored as a node with the address of the next node. A linked list data structure is a collection of nodes stored in contiguous memory.

#### Non-Linear Data Structures

If all elements are arranged in linear order then it is referred to as Linear Data Structures. All elements are stored in the same format that is elements are stored in Non-hierarchical way.

Types of Non-Linear Data Structures are given below:

1. Tree

2. Graph

In this data structure, the data is stored in a Non-linear order. The data stored in any sequence and non-linear arrangement. Each item is cab be connected to two or more items. Non-linear data can be retrieved (access) from anywhere.

Example: Tree, Graph

##### 1. Tree

The tree is Non-linear data structure where data is stored in hierarchical order. The tree is a set of a node which has a starting node called as a root node and all other connected with that node to form a tree. Each node contains pointers to point to its adjacent node.

##### 2. Graph

The graph is a set of a node connected with edges.

### Operations on data structure

##### 1) Traversing

Traversing the data structure means visiting each element of the data structure in order to perform some specific operation like searching or sorting.

**Example:**

If we need to calculate the average of the marks obtained by a student in 6 different subjects, we need to traverse the complete array of marks and calculate the total sum, then we will divide that sum by the number of subjects i.e. 6, in order to find the average.

##### 2) Insertion

Insertion can be defined as the process of adding the elements to the data structure at any location. If the size of the data structure is n then we can only insert n-1 data elements into it.

##### 3) Deletion

The process of removing an element from the data structure is called Deletion. We can delete an element from the data structure at any random location.

If we try to delete an element from an empty data structure then underflow occurs.

##### 4) Searching

The process of finding the location of an element within the data structure is called Searching. There are two algorithms to perform searching, Linear Search and Binary Search. We will discuss each one of them later in this tutorial.

##### 5) Sorting

The process of arranging the data structure in a specific order is known as Sorting. There are many algorithms that can be used to perform sorting, for example, insertion sort, selection sort, bubble sort, etc.

##### 6) Merging

When two lists List A and List B of size M and N respectively, of similar type of elements, clubbed or joined to produce the third list, List C of size (M+N), then this process is called merging.