### Day 21: Data Structures and Algorithms Basic

Hello Dear Students,

ARR[0] ARR[1] ARR[2] ARR[3]

Hope you all are doing good....

From today, we are going to study our next Unit which is Data Structures and Algorithms. Today we will cover its basics,

Let's get started....

**- Data Structure basically 2 words ka combination hai, Data, and Structure. So, data means some values which are used to represent some facts or observations. Processed form of data is known as Information as we all know. So, structure means design or architecture basically. So, Data Structure means data ka design means ki data kis form mein store kiya jata hai. In formal language, Data Structure is the organized collection of data in a mathematical or logical way.**

__DATA STRUCTURES__According to Nikaulus,

*ALGORITHM + DATA STRUCTURE = PROGRAM*

**- Data structure means data ko kis structure mein store kiya jata hai. So, there are basically 2 categories jiske according data ko store kiya jata hai -**

__CLASSIFICATION OF DATA STRUCTURES__**- Linear data structure mein data ko linear way mein store kiya jata hai, linear means one after another. In this, data elements are organized sequentially and easy to implement. Example, Array, stack, queue, link list.**

__Linear Data Structure____Non Linear Data Structure -__Non linear data structure mein data linear way mein store nahi kiya jata and sequential and organized nahi hota and ek relationship hota hai data elements mein like tree and graph in which data not stored one after another but stored in special relationships like parent node, child node, etc.

**LINEAR DATA STRUCTURE**

**ARRAY**- Array is collection of same type of data elements, means array mein same type data ko store kiya jata hai. Isme data ko store karne ke liye contiguous memory locations hote hain means ki data is memory mein store kiya jata hai agar hum data ko array mein store karate hain. Contiguous memory location means ek hi block memory mein data ko store karna. Jab hum array mein kuch data ko store karate hain to wo only 1 single block mein store hota hai, access is fast. For example,

100 | 200 | 300 | 400 |

*Memory representation of array*

Array always starts from 0. Thus, the maximum size of array is

*n-1*, n is total number of data elements. For example, above array ARR, maximum size is 4-1=3.Array which is either in row or column is called Linear Array. Array with both rows and columns are non linear arrays.

**LINK LIST**- Link list mein data ko store karne ke liye various nodes hote hain jo ek doosre ke saath connected hote hain. It stores the data non contiguous memory location means sinle block mein data store nahi hota and different small segments hote hain data ko store karne ke liye which are the nodes. Link list also known as Linked List and isme various nodes hote hain. Ek node ke 2 parts hote hain- Information part and next pointer field. Information part mein data ko store karaya jata hai and next pointer field mein next node ka address diya jata hai.

In above linked list, there are various nodes, Start node from where link list starts, 100, 200 are information part of nodes and next is the next pointer part for pointing next node address, X is the null pointer which shows end of the link list.

**STACK**- Stack is the data structure based on LIFO(Last In First Out). Jaise ek books ka stack hota hai, books ko one after another rakha jata hai, waise hi stack mein data ko store kiya jata hai one after the another. LIFO means jo sabse pehle store huya hai data wo sabse last mein access hoga and jo sabse last mein store kiya gya data hai wo sabse pehle access hoga.

100 |

200 |

300 |

400 |

Top of the stack is 100. So, agar hum kuch v insertion or deletion karenge to wo only and only Top se ki karenge. In Stack, insertion ko Push operation kaha jata hai and deletion ko Pop operation kaha jata hai.

**QUEUE**- Queue means line basically jaise hum ticket counters, etc, mein line mein khade hote hain, vaise hi queue data structure mein data ko line mein store kiya jata hai. It is based on FIFO(First In First Out), means jo sabse pehla line mein aya wo sabse pehla access hoga and jo sabse last mein hai wo sabse last mein access hoga. In queue, insertions is on last and deletion is from first. The insertion operation on last element is known as REAR and the deletion from front is known as FRONT or HEAD.

100 | 200 | 300 | 400 | 500 |

0 1 2 3 4

Here, FRONT=0 and REAR=4. Insertion is on 5 and deletion is from 0.

*NON LINEAR DATA STRUCTURE***TREE**- Tree data structure mein Parent-Child relationship mein data ko store kiya jata hai. Sabse pehle Parent node hoti hai, then uske child nodes, and so on. It is not sequential and it is hierarchical structure. Tree has nodes and edges. Nodes means jisme data ko store kiya jata hai like parent and child nodes, and edges means lines jo nodes ko connect karti hai.

In this, it is tree, which have A,B,C,D,E,and F are nodes and the lines connecting these nodes are edges. The parent node is A and its child node is B, and C.

GRAPH - Graph is same like tree. It is non linear data structure. Graph ki form mein data store kiya jata hai and it also has edges and nodes. Tree with cycles is known as Graph and Graph without cycle is known as Tree. Tree is hierarchical structure and the graph is hierarchical and cyclic structure.

The above is a graph connecting various nodes with edges.

Best of Luck Students,

Do share and subscribe if you like our efforts.

Do visit our website UGC NET EXPERTS regularly for more content and for daily tests.

Regards,

**UGC NET EXPERTS**