Bird
0
0
DSA Cprogramming~10 mins

Array Deletion at Middle Index 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 elements left after deleting an element at index mid.

DSA C
for (int i = mid; i < n - 1; i++) {
    arr[i] = arr[1];
}
Drag options to blanks, or click blank then click option'
A[i + 1]
B[i - 1]
C[mid]
D[i]
Attempts:
3 left
💡 Hint
Common Mistakes
Using arr[i - 1] which shifts elements incorrectly.
Using arr[mid] which copies the same element repeatedly.
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 addition which increases the size incorrectly.
Using multiplication or division which changes size wrongly.
3fill in blank
hard

Fix the error in the loop condition to avoid accessing out of bounds.

DSA C
for (int i = mid; 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 <= causes out of bounds access.
Using > or >= causes the loop to skip or run incorrectly.
4fill in blank
hard

Fill both blanks to print the array elements after deletion.

DSA C
for (int i = 0; i [1] n; i++) {
    printf("%d ", arr[2]);
}
Drag options to blanks, or click blank then click option'
A<
B<=
C[i]
D[n]
Attempts:
3 left
💡 Hint
Common Mistakes
Using <= causes printing one extra element.
Using arr[n] causes out of bounds access.
5fill in blank
hard

Fill all three blanks to delete the middle element and print the updated array.

DSA C
int mid = n [1] 2;
for (int i = mid; i < n [2] 1; i++) {
    arr[i] = arr[i [3] 1];
}
n = n - 1;
for (int i = 0; i < n; i++) {
    printf("%d ", arr[i]);
}
Drag options to blanks, or click blank then click option'
A/
B+
C-
D*
Attempts:
3 left
💡 Hint
Common Mistakes
Using subtraction instead of addition in arr[i] assignment.
Using multiplication or wrong loop condition.