It is a mathematical and logical model of organizing the interrelated data is called data structure.
Here, we have collection of that data must be interrelated and must be organized in an efficient manner which is predefined manner in a mathematical order. For example if we have data structure called Queue then we must organize the data in such a way so that it follow first in first out or if we have data structure called stack then it must follow lasting first out and the data should be in linear manner. So, queue and stack is mathematical predefined structure of organising the data.
Data is all about storage and operation we can perform on that data is called logical model. Example insertion (called Push in stack) deletion (called Pop in stack). It may vary depend on requirement.
Types of Data Structure
Based on Arrangement
It is of two types:
Linear Data Structure: Elements are arranged linear or sequential fashion there are multiple types of linear data structure such as Array, Linked list, Stack, and Queue, etc.
It is a single level organisation of data.
Non-Linear Data Structure: Elements feature arranged in nonlinear fashion. There are multiple types of non linear data structures such as Tree, Graph and Hash Table, etc.
It is a multi level organisation of data.
Based on usage
It is categorised in three types -
Container Data Structure: Data structure that are only used to store the data are called container data structure such as Array and Linked List, etc.
Indexing Data Structure: Data structure that are used for searching an element in a collection of data is called indexing data structure for example Binary Search Tree, B-Tree, B+ Tree, AVL Tree and Hash Table, etc.
Priority Data Structure: Data structure in which the elements hold some priority to perform an operation especially delete operation based on that priority value or priority data structure for example Queue, Stack and Heap, etc.
Why Data Structure?
Let's put it simple - to solve any problem, we need some algorithm. It can be any problem and for each algorithm we need to provides some input and expect a legitimate output. For that we need some mechanism to put our data at input and store the output data. So, that our algorithm take minimal amount of time to solve our problem and that mechanism is called Data Structure.
To run our algorithm with high performance we need best data structure so that input, output and intermediate results can be accessed or generated in minimum efforts.
Operations on Data Structure
There are multiple operations we can perform on data structure such as -
Traversing: Visiting elements at least and at most once in a data structure.
Insertion: Adding an element in data structure.
- All the data structure have some limited capacity. When data structure is full then further insertion is not possible that is called Overflow.
Deletion: Removing an element in data structure, it depend on data structure which element should be deleted.
- When data structure is empty and no further deletions are possible that is called Underflow.
Searching: Finding an element in data structure and return the index or address (in case of non-linear data structure)value. The result may be successful search or unsuccessful search. On Successful search it will return the address of index value. In case of unsuccessful search it will return LB - 1 or NULL (in case of non linear data structure).
Merging: Combining two data structure of same type into one.
Sorting: Arriving data structure in either ascending or descending order. There are multiple types of sorting algorithm such as bubble sort, quick sort, merge sort, insertion sort, selection sort, etc.
Conclusion
Data structures are essential models for organizing data efficiently, defining arrangements like queues or stacks. They categorize as linear (e.g., arrays) or non-linear (e.g., trees), serving distinct purposes. Integral to algorithmic efficiency, data structures facilitate optimal problem-solving by storing and manipulating data systematically. Operations include traversing, insertion, deletion, searching, merging, and sorting. In essence, they are foundational for streamlined access and manipulation of data for effective problem resolution.