Programming Pandit

c/c++/c#/Javav/Python


Latest Update

Sunday, August 30, 2026

Data Structure Operations: insertion, deletion, traversal etc.

 

Data Structure Operations

Data Structure Operations are the basic operations performed on data elements to store, access, modify, and manage data efficiently. The common operations are insertion, deletion, traversal, searching, sorting, and merging.

OperationMeaningExample
1. InsertionAdding a new element to a data structureInsert 40 into [10, 20, 30][10, 20, 30, 40]
2. DeletionRemoving an existing elementDelete 20[10, 30, 40]
3. TraversalVisiting/accessing each element of the data structure, usually onceDisplay all elements: 10 20 30 40
4. SearchingFinding a particular element in the data structureSearch for 30
5. SortingArranging elements in a particular order, such as ascending or descending[30, 10, 20][10, 20, 30]
6. MergingCombining two similar data structures into one[10,20] + [30,40][10,20,30,40]
7. UpdatingChanging the value of an existing element[10,20,30][10,25,30]

1. Insertion

Insertion means adding a new data element to an existing data structure.

For example:

Before:  10  20  30
Insert:  40
After:   10  20  30  40

The position of insertion depends on the data structure. In an array, an element may be inserted at the beginning, middle, or end.


2. Deletion

Deletion means removing an existing element from a data structure.

Before:  10  20  30  40
Delete:  30
After:   10  20  40

After deletion, the remaining elements may need to be rearranged depending on the data structure.


3. Traversal

Traversal means visiting each element of a data structure systematically.

For an array:

int A[5] = {10, 20, 30, 40, 50};

for(int i = 0; i < 5; i++)
    cout << A[i] << " ";

Output:

10 20 30 40 50

Traversal is particularly important because many other operations, such as searching and displaying data, require traversal.


4. Searching

Searching means finding whether a particular element exists in the data structure and, if required, determining its position.

Example:

Data:    10  20  30  40  50
Search:  30
Result:  Element found at position 3

Common searching techniques include:

  • Linear Search

  • Binary Search


5. Sorting

Sorting means arranging data elements according to a specified order.

Ascending:

40  10  30  20
        ↓
10  20  30  40

Descending:

40  30  20  10

Common sorting algorithms are Bubble Sort, Selection Sort, Insertion Sort, Merge Sort, and Quick Sort.


6. Merging

Merging means combining two data structures of the same or compatible type into a single structure.

List 1: 10  20  30
List 2: 40  50  60

Merged: 10  20  30  40  50  60

7. Updating

Updating means replacing or modifying the value of an existing element.

Before:  10  20  30
              ↓
           Change 20 to 25

After:   10  25  30

In short

The basic operations on data structures can be remembered as:

Insertion → Deletion → Traversal → Searching → Sorting → Merging → Updating

For an introductory Data Structures lecture, the first three—Insertion, Deletion, and Traversal—are especially important because they form the foundation for understanding arrays, linked lists, stacks, queues, and other data structures.

No comments:

Post a Comment