Accordingly to the Wikipedia article on dynamic arrays, inserting/deleting at the end of the array is O(1) while inserting/deleting from the middle is O(n). Why exactly is that?
Also - if I have a dynamic array with 5 elements and I insert a new element at position 6 the operation is O(n) whereas if I use the function to append to the end of the array it is O(1). Isn't this the same operation assuming the array doesn't need to resize in either case? Or does appending to the dynamic array really insert the new element somewhere besides position 6?
Thanks!
EDIT: I think my main confusion is the difference between inserting at the end of the array and inserting at a specific position that is equivalent to the end of the array.
I suppose a pointer to the memory address of the end of the array is kept handy and that is why the append operation is quick. Conversely, if I specify a precise position (even if it is the end of the array) it won't know that inserting at that position is tantamount to using the aforementioned memory address so it has to traverse the entire array, eh?