Learn CS Visual

How Array Insertion and Deletion Work

Inserting or deleting an element in an array can require moving the elements that follow it. Inserting at the front means shifting every existing element back by one, while inserting at the end doesn't require moving anything else. How many elements move depends on where you insert or delete.

Inserting at the front of a 6-element array, how many elements need to move?