Common operations on various Data Structures, Exercises of Data Structures and Algorithms

Common operations on various Data Structures

Typology: Exercises

2022/2023

Uploaded on 02/17/2024

thaw-maung-oo
thaw-maung-oo 🇲🇲

5 documents

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Common operations on various Data Structures
Operations on different Data Structures:
There are different types of operations that can be performed for the manipulation of data
in every data structure. Some operations are explained and illustrated below:
Traversing: Traversing a Data Structure means visiting the element stored in it. It visits
data in a systematic manner. This can be done with any type of DS.
Searching: Searching means finding a particular element in the given data structure. It is
considered successful when the required element is found. Searching is the operation that
we can perform on data structures like an array, linked list, tree, graph, etc.
Insertion: It is the operation that we apply to all the data structures. Insertion means
adding an element to the given data structure. The operation of insertion is successful
when the required element is added to the required data structure. It is unsuccessful in
some cases when the size of the data structure is full and when there is no space in the
data structure to add any additional element. The insertion has the same name as an
insertion in the data structure as an array, linked list, graph, or tree. In stock, this
operation is called Push. In the queue, this operation is called Enqueue.
Deletion: It is the operation that we apply to all the data structures. Deletion means
deleting an element in the given data structure. The operation of deletion is successful
when the required element is deleted from the data structure. The deletion has the same
name as a deletion in the data structure as an array, linked list, graph, tree, etc. In stock,
this operation is called Pop. In Queue this operation is called Dequeue.
Below is the program to illustrate dequeue in Stack, Queue, and Linkedlist:
Some other methods:
Create: –
It reserves memory for program elements by declaring them. The creation of a
data structure Can be done during
1. Compile-time
2. Run-time.
You can use the malloc() function.
pf2

Partial preview of the text

Download Common operations on various Data Structures and more Exercises Data Structures and Algorithms in PDF only on Docsity!

Common operations on various Data Structures

Operations on different Data Structures: There are different types of operations that can be performed for the manipulation of data in every data structure. Some operations are explained and illustrated below:  Traversing: Traversing a Data Structure means visiting the element stored in it. It visits data in a systematic manner. This can be done with any type of DS.  Searching: Searching means finding a particular element in the given data structure. It is considered successful when the required element is found. Searching is the operation that we can perform on data structures like an array, linked list, tree, graph, etc.  Insertion: It is the operation that we apply to all the data structures. Insertion means adding an element to the given data structure. The operation of insertion is successful when the required element is added to the required data structure. It is unsuccessful in some cases when the size of the data structure is full and when there is no space in the data structure to add any additional element. The insertion has the same name as an insertion in the data structure as an array, linked list, graph, or tree. In stock, this operation is called Push. In the queue, this operation is called Enqueue.  Deletion: It is the operation that we apply to all the data structures. Deletion means deleting an element in the given data structure. The operation of deletion is successful when the required element is deleted from the data structure. The deletion has the same name as a deletion in the data structure as an array, linked list, graph, tree, etc. In stock, this operation is called Pop. In Queue this operation is called Dequeue. Below is the program to illustrate dequeue in Stack, Queue, and Linkedlist: Some other methods: Create: – It reserves memory for program elements by declaring them. The creation of a data structure Can be done during

  1. Compile-time
  2. Run-time. You can use the malloc() function.

Selection:- It selects specific data from present data. You can select any specific data by giving conditions in the loop. Update It updates the data in the data structure. You can also update any specific data by giving some conditions in a loop like a select approach. Sort Sorting data in a particular order (ascending or descending). We can take the help of many sorting algorithms to sort data in less time. Example: bubble sort which takes O(n^2)time to sort data. There are many algorithms present like merge sort, insertion sort, selection sort, quick sort, etc. Merge Merging data of two different orders in a specific order may ascend or descend. We use merge sort to merge sort data. Split Data Dividing data into different sub-parts to make the process complete in less time.