Bird
0
0
DSA Cprogramming~20 mins

Array Deletion at Beginning in DSA C - Practice Problems & Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Array Deletion Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
Output after deleting first element from array
What will be the output of the following C code after deleting the first element from the array?
DSA C
int arr[] = {10, 20, 30, 40, 50};
int n = 5;

// Delete first element by shifting
for (int i = 0; i < n - 1; i++) {
    arr[i] = arr[i + 1];
}
n--;

for (int i = 0; i < n; i++) {
    printf("%d ", arr[i]);
}
A50 40 30 20
B10 20 30 40 50
C30 40 50
D20 30 40 50
Attempts:
2 left
💡 Hint
After deleting the first element, all elements shift left by one position.
Predict Output
intermediate
1:00remaining
Resulting array size after deletion
Given an array of size 7, after deleting the first element by shifting, what is the new size of the array?
DSA C
int arr[7] = {5, 10, 15, 20, 25, 30, 35};
int n = 7;

// Delete first element
for (int i = 0; i < n - 1; i++) {
    arr[i] = arr[i + 1];
}
n--;
A7
B6
C5
D0
Attempts:
2 left
💡 Hint
Deleting one element reduces the size by one.
🔧 Debug
advanced
2:00remaining
Identify the bug in array deletion code
What is the bug in the following code that deletes the first element of an array?
DSA C
int arr[] = {1, 2, 3, 4, 5};
int n = 5;

for (int i = 0; i <= n - 1; i++) {
    arr[i] = arr[i + 1];
}
n--;

for (int i = 0; i < n; i++) {
    printf("%d ", arr[i]);
}
ALoop condition should be i < n - 1, not i <= n - 1
Bn should be incremented, not decremented
CArray size is not initialized
DNo bug, code works correctly
Attempts:
2 left
💡 Hint
Check the loop boundary to avoid accessing out of bounds.
Predict Output
advanced
2:00remaining
Output after multiple deletions at beginning
What is the output after deleting the first element twice from the array?
DSA C
int arr[] = {100, 200, 300, 400, 500};
int n = 5;

// Delete first element twice
for (int d = 0; d < 2; d++) {
    for (int i = 0; i < n - 1; i++) {
        arr[i] = arr[i + 1];
    }
    n--;
}

for (int i = 0; i < n; i++) {
    printf("%d ", arr[i]);
}
A100 200 300 400 500
B200 300 400 500
C300 400 500
D400 500
Attempts:
2 left
💡 Hint
Each deletion shifts elements left and reduces size by one.
🧠 Conceptual
expert
1:30remaining
Time complexity of deleting first element in array
What is the time complexity of deleting the first element from an array of size n by shifting all elements left by one?
AO(n)
BO(1)
CO(n^2)
DO(log n)
Attempts:
2 left
💡 Hint
Consider how many elements need to be moved.