You are on page 1of 3

DSA LAB

Lab-02 (11-10-2023)

Insertion Problems
Task 1:
Write a program to insert an element at a specific position in a 1D array.
Requirements:
Suppose you have an array of size 8 with elements: {12, 45, 78, 34, 56, 90, 23, 67}.
You are required to insert an element at index 3.
The element to be inserted is 50.
Display the updated array.
Task 2:
Write a program to insert an element at a specific position in a 2D array.
Requirements:
Suppose you have a 2D array with dimensions 3x3:

1 2 3

4 5 6

7 8 9

You are required to insert the element 10 at row 2 and column 1.

Display the updated 2D array.

Deletion Problems
Task 3:
Write a program to delete an element at a specific position in a 1D array.

Requirements:

Suppose you have an array of size 7 with elements: {10, 20, 30, 40, 50, 60, 70}.

You are required to delete the element at index 4.

Display the updated array.

Task 4:
Write a program to delete an element at a specific position in a 2D array.

Requirements:

Suppose you have a 2D array with dimensions 3x4:

10 20 30 40

50 60 70 80

90 100 110 120

You are required to delete the element at row 1 and column 3.

Display the updated 2D array.

Traversal Problems
Task 5:
Write a program to traverse (display) the elements of a 1D array.

Requirements:

Suppose you have an array of size 6 with elements: {5, 12, 24, 36, 48, 60}.

Display all the elements of the array one by one.

Task 6:
Write a program to traverse (display) the elements of a 2D array.
Requirements:
Suppose you have a 2D array with dimensions 2x3:

22 45 68

12 35 58

Display all the elements of the 2D array row by row.

You might also like