August 2017
Intermediate to advanced
222 pages
5h 3m
English
The efficiency of inserting a new piece of data inside an array depends on where inside the array you’d like to insert it.
Let’s say we wanted to add "figs" to the very end of our shopping list. Such an insertion takes just one step. As we’ve seen earlier, the computer knows which memory address the array begins at. Now, the computer also knows how many elements the array currently contains, so it can calculate which memory address it needs to add the new element to, and can do so in one step. See the following diagram:

Inserting a new piece of data at the beginning or the middle of an array, however, is a different story. In these cases, ...