Recall & Review
beginner
What happens to the elements after deleting an element at the middle index of an array?
All elements after the deleted index shift one position to the left to fill the gap.
Click to reveal answer
beginner
Why can't we just remove an element from the middle of a static array without shifting elements?
Because arrays have fixed size and continuous memory, removing an element leaves a gap that must be filled by shifting elements.
Click to reveal answer
beginner
In C, after deleting an element from an array, what must be updated to reflect the new size?
The variable that stores the array's current size must be decreased by one.
Click to reveal answer
intermediate
What is the time complexity of deleting an element at the middle index of an array?
O(n), because elements after the deleted index must be shifted one by one.
Click to reveal answer
beginner
Show the steps to delete the element at index 2 from the array [10, 20, 30, 40, 50].
1. Remove element 30 at index 2.<br>2. Shift elements 40 and 50 left by one.<br>3. New array: [10, 20, 40, 50].<br>4. Decrease size by 1.
Click to reveal answer
What must you do after deleting an element from the middle of an array?
✗ Incorrect
After deletion, elements after the deleted index must shift left to fill the gap.
What is the time complexity of deleting an element at the middle index of an array of size n?
✗ Incorrect
Shifting elements after the deleted index takes O(n) time.
If an array has 5 elements and you delete the element at index 2, what is the new size of the array?
✗ Incorrect
The size decreases by one after deletion.
Which of these is NOT a step in deleting an element from the middle of an array?
✗ Incorrect
Static arrays do not require new memory allocation for deletion.
What happens if you try to delete an element at an invalid index in an array?
✗ Incorrect
Accessing invalid index leads to undefined behavior or runtime error.
Explain how to delete an element at the middle index of an array and update its size.
Think about filling the gap left by the deleted element.
You got /3 concepts.
Describe why deleting an element in the middle of a static array requires shifting elements.
Consider how arrays store elements in memory.
You got /3 concepts.
