Adding a new item
To add an element to a one-dimensional array, all we have to do is to increase the logical dimension n of the vector, and to store the new element in the box we freed.
Inserting a new item
Assuming we have a string "V" with "n" elements, and we want to insert the element "new_number" at position "p".
In the image above, I inserted the element "13" at position 3. How did I proceed?
We first increased the logical size (n) by one element
I went through the vector from the tail "and pulled" all the elements after the index 3 with one position to the right
I replaced the value in V[3]
Deleting an item
Assuming we have a string "V" with "n" elements, and we want to delete the element at position "p".
In the image above, I deleted the element on position 2. How did I proceed?
We traveled the vector starting from position "p"
I dragged all the elements to the left
I decreased n by one unit