Bird
0
0
DSA Cprogramming~10 mins

Array Deletion at Beginning in DSA C - Interactive Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to shift all elements left by one to delete the first element.

DSA C
for(int i = 0; i < n - 1; i++) {
    arr[i] = arr[[1]];
}
Drag options to blanks, or click blank then click option'
Ai
Bi - 1
Ci + 1
Dn - i
Attempts:
3 left
💡 Hint
Common Mistakes
Using arr[i - 1] causes out-of-bound access at i=0.
Using arr[i] does not shift elements.
Using arr[n - i] accesses wrong indices.
2fill in blank
medium

Complete the code to reduce the array size after deletion.

DSA C
n = n [1] 1;
Drag options to blanks, or click blank then click option'
A+
B*
C/
D-
Attempts:
3 left
💡 Hint
Common Mistakes
Using + increases the size incorrectly.
Using * or / changes size incorrectly.
3fill in blank
hard

Fix the error in the loop condition to avoid out-of-bound access.

DSA C
for(int i = 0; i [1] n - 1; i++) {
    arr[i] = arr[i + 1];
}
Drag options to blanks, or click blank then click option'
A<
B<=
C>
D>=
Attempts:
3 left
💡 Hint
Common Mistakes
Using <= n causes out-of-bound access.
Using > or >= is incorrect for forward loops.
4fill in blank
hard

Fill both blanks to complete the function that deletes the first element of the array.

DSA C
void deleteFirst(int arr[], int *n) {
    for(int i = 0; i [1] *n - 1; i++) {
        arr[i] = arr[i [2] 1];
    }
    (*n)--;
}
Drag options to blanks, or click blank then click option'
A<
B<=
C+
D-
Attempts:
3 left
💡 Hint
Common Mistakes
Using <= causes out-of-bound access.
Using -1 instead of +1 accesses wrong elements.
5fill in blank
hard

Fill all three blanks to print the array after deleting the first element.

DSA C
for(int i = [1]; i [2] n; i[3]) {
    printf("%d ", arr[i]);
}
Drag options to blanks, or click blank then click option'
A0
B<
C++
D1
Attempts:
3 left
💡 Hint
Common Mistakes
Starting from 1 skips the new first element at index 0.
Using i-- or wrong loop condition causes errors.