Recall & Review
beginner
What happens when you delete the first element of an array?
The first element is removed, and all other elements shift one position to the left to fill the gap.
Click to reveal answer
beginner
Why do we need to shift elements after deleting the first element in an array?
Because arrays have fixed positions, shifting keeps the array continuous without empty spaces.
Click to reveal answer
beginner
Show the array after deleting the first element from [10, 20, 30, 40].
After deletion, the array becomes [20, 30, 40]. The elements 20, 30, and 40 shift left by one position.
Click to reveal answer
intermediate
What is the time complexity of deleting the first element in an array?
It is O(n) because all elements after the first must be shifted one position to the left.
Click to reveal answer
intermediate
Can we delete the first element of an array without shifting elements?
No, because arrays store elements in continuous memory. To keep order, shifting is necessary.
Click to reveal answer
What must be done after deleting the first element of an array?
✗ Incorrect
After deleting the first element, all other elements must shift left to fill the empty space.
What is the time complexity of deleting the first element in an array of size n?
✗ Incorrect
Deleting the first element requires shifting all other n-1 elements, so time complexity is O(n).
If the array is [5, 10, 15], what is the array after deleting the first element?
✗ Incorrect
The first element 5 is removed, and the rest shift left, resulting in [10, 15].
Why can't we just mark the first element as deleted without shifting?
✗ Incorrect
Arrays store elements in continuous memory, so gaps are not allowed; shifting maintains continuity.
What happens to the size of the array after deleting the first element?
✗ Incorrect
Logically, the array size decreases by one because one element is removed.
Explain step-by-step how to delete the first element of an array and update the array.
Think about what happens to each element after deletion.
You got /4 concepts.
Describe the time complexity of deleting the first element in an array and why it is that way.
Consider how many elements move after deletion.
You got /4 concepts.
