 # DATA STRUCTURES AND ALGORITHMS￼

## INTRODUCTION

Let’s understand about DATA STRUCTURES AND ALGORITHMS.

What is a data structure?

The data structure is storage used to store and organize the data. In data structures, arranging the data take place in a way that the data is stored and retrieved efficiently. Data structures are used almost everywhere in the programming world.

Algorithms are the set of instructions to be followed to achieve a particular problem. The algorithm takes a set of inputs to get the desired output. These algorithms are being implemented on different data structures to solve problems efficiently. Algorithms are written in various steps which resemble the code in a human-understandable language that can be used to understand the code for a particular problem.

Let’s look at the sample algorithm for the addition of two numbers.

``````Step 1 : Start

Step 2 : Declare three variables a, b and sum

Step 3 : Read The values of a and b

step 4 : add a and b and assign the result to sum
Sum <- a + b

Step 5 : Display sum

step 6 : Stop``````

Let’s understand primitive and non-primitive data structures.

There are different kinds of basic and advanced data structures are being implemented around the world. Let’s know more about the classification of the data structures.

This is the classification of the data structures. Let’s know more about the classification of the data structures.

## Linear data structures:

these are the kind of data structures that are arranged in a contiguous manner, that is where each element is attached to its previous and next elements sequentially, known as linear data structures. These linear data structures are again classified into two types. They are

1.      Static data structure
2.      Dynamic data structure

### Static data structure:

static data structures hold fixed memory sizes.  Accessing the elements in these static data structures will be easy. The array data structure is an example of a static data structure.

• Array data structure: array elements are stored in a contiguous manner. All the elements in the array are of the same data type.

### Dynamic data structures:

In dynamic data structures, the size is not fixed, later it can be updated during runtime according to the input. These data structures are considered as efficient than static data structures as memory is managed efficiently according to the need of the user.

Stack, queue, and linked lists are examples of dynamic data structures.

• stack data structure: stack data structure follows the LIFO principle, which means the element which is inserted last will be removed first.

Queue data structure:

• queue data structure follows the FIFO principle, which means the element which is inserted first will be removed last.

linked lists are the data structures that are a series of nodes. Each node consists of the data value and the address to the next node. The linked list data structure is as similar to an array data structure.

## Non-linear data structures:

these are the kind of data structures that are not arranged in sequential order or linearly known as non-linear data structures. Implementation of non-linear data structures is a bit difficult when compared with the implementation of linear data structures. These non-linear data structures contain different levels, so it is not possible to traverse every element in a single visit. Examples of these non-linear data structures are trees, graphs, etc.

Tree data structure:

the tree data structure consists of nodes at different levels which are linked together. Tree data structure forms a hierarchical relationship. every two nodes in a tree are related in a parent-child manner. Binary trees, binary search trees, AVL trees, red-black trees, etc are different kinds of trees formed according to their structure and efficiency.

Graph data structure:

the graph data structure consists of vertices and edges. Vertices in the graphs are used to store the data and edges are used to represent the relationship between the vertices.

We came to know about linear and non-linear data structures, In thee next article, we will know about the major differences between them.

Stay tuned!  