Data Structure are used to Organize and Store Data So That we can Access and manipulate it Efficiently
Operations on Data Structure refer to Action that can be performed on these Data Structure's to add, remove , modify or Retrieve data.
1) Insertion
Insertion Refers to Adding a new Element at any Location into a data Structure.
If the Size of Data Structure in n then We can only insert n-1 Data Element to it.
2) Deletion
- Deletion Refers to Removing an Element at any Location into a Data Structure.
3) Sorting
The Process of Arranging the Data in a Specific Order is Called Sorting.
There are Many Algorithms that can be used to Perform Sorting
For Example :- Insertion Sort , Selection Sort, Bubble Sort Etc.
4) Traversing
Every Data Structure Contains a Set of Data Elements.
The Process of Visiting or Accessing each Element of a Data Structure is Known as Traversing
5) Searching
Searching refers to the Process of Finding an Element in a Data Structure.
There are Two Algorithms to Perform Searching
a) Linear Search
b) Binary Search
6) Merging
- Merging is the Process of Combining Two or More Data Set into Single Data Set.
For Example
=> Group 1 : [1,4,7]
=> Group 2 : [2,3,6]
- When We merge Then we get [1,2,3,4,6,7]
Step 1 :- Compare The Smallest Numbers
Start by Looking at the first Smallest Number in both Group
- Group 1 :- The First Number is 1
- Group 2 :- The First Number is 2
Now Compare These two Number 1 (From Group 1 ) is Smaller than 2 (From Group 2)
So we Pick 1 and Add it to the New merged Group.
Step 2 :- Move to Group 1
Since we Just picked 1 From Group 1, We need move to the Next number in Group 1 (which is 4)
- Group 1 :- The Next Number is 4
- Group 2 :- The First Number is 2
Compare 4 From Group 1 and From Group 2.
Since 2 is Smaller than 4 , we Take 2 and it to the merged array.
Merged Array:- [1,2]
Moved to the next element in Group 2.
Step 3 :- Continue Comparing the Next Smaller Number.
Compare 4 From Group 1 and 3 From From Group 2.
Since 3 is Smaller then 4, we add three to the Merged Array.
Merged Array :- [1,2,3]
Move To the next Element in Group 2 Which is 6.
Step 4 :- Compare the Next Number Smallest Number
Compare 4 From Group 1 and 6 From Group 2.
Since 4 is Smaller than 8 , we add 4 to merged Array.
Merged Array:- [1,2,3,4]
Step 5 :- Compare the Next Number Smallest Number
Compare 7 From Group 1 and 6 From Group 2.
Since 6 is Smaller than we add 6 to the merged Array
Merged Array:- [1,2,3,4,6]
Moved to the Next Element in Group 2 but Group 2 in now Exhausted (No more Element left).
Step 5 :- Append The Remaining Element
Since Group 2 is Exhausted We Append The Remaining Element From Group 1 to the Merged Array.
Add 7 From Group 1 to the Merged Array.
Merged Array : - [1,2,3,4,6,7]
=> Final Merged Array:- [1,2,3,4,6,7]