Table of Contents
Operations on Data Structure in C
There are various operations that can be perform on Data Structure. Some of them are common data structure operations it means they can be perform on both Linear and non Linear Data Structure.
Various operations on Data Structure in C are given below –
- Traversing
- Insertion
- Deletion
- Search
- Sorting
- Merging
Traversing, insertion, deletion and Searching are the common operations perform on all Types of Data Structure.
Let us understand each operations on data structure one by one.
Traversing Operation on Data Structure
- Every Data Structure contains the set of data elements.
- Traversing operation on Data Structure means visiting each element of the data structure.
- After traversing the data structure we can perform a specific task on those elements.
- Various Tree Traversal Methods are used to traverse nodes in Binary Tree Data Structure.
For Example If we need to calculate the average of the marks obtained by a student in 6 different subject, 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.
Insertion Operation in Data Structure
- Insertion operation in Data Structure in Data Structure represents the adding new element to the existing data structure at a specific location.
- If we can perform insertion operation in both Linear Data Structure such as Array , Stack, Queue , Linked List and also in non linear data structure like Tree and Graph.
- Data Structure like Array , Stack and Queue has a fixed size so we can insert number of elements or data value only up to the the size of array ,stack or queue.
- Linked list is a Dynamic Data Structure there is no fixed size whenever we have to insert a new element we simply create node to store the data element and insert it into linked list.
Deletion Operation in Data Structure
- The process of removing an element from the existing 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.
Searching Operation on Data Structure
- The process of finding the location of an existing element within a data structure is called Searching.
- Linear Search and Binary Search are two most popular searching algorithms used to search an element in Array.
- Search operation is also applicable on Linked List, Tree and Graph Data Structure.
- There are two algorithms to perform searching, Linear Search and Binary Search.
- In Graph Data Structure Depth First Search and Breadth First Search are two algorithms which are used to search an element in graph.
Sorting Operation on Data Structure
- The process of arranging the data structure elements in a specific order either descending or ascending is known as Sorting.
- There are many algorithms that can be used to perform sorting, for example, Insertion Sort, Selection Sort, Bubble Sort, Merge Sort etc.
Merging Operation on Data Structure
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.
Conclusion and Summary
In this tutorial we have discussed about six data structure operations.
I hope meaning of each data structure operation will be clear to student.
Next Tutorial – Types of Data Structure