Calculating Time complexity of a Dynamic Based Array.
In the text i am reading it mentions two approaches for dynamically increasing an array.
Dynamic Array Approach 1
The first approach states that you can construct an array of size 1 and dynamically increase it for every time you push a new data to the array. For instance if you push new data then you create a new array of old size of the array plus 1 and copy all the elements from the old array to the new one and then add the new data. The text is suggesting that time complexity for this approach is 0(N^2). I am not sure how though? I thought the time complexity is O(N) since you are creating a new array for every new element where you can have N new elements and also you are copying the old elements which is again approximated to N. Therefore i would think that complexity is O(N).
Dynamic Array Approach 2
The second approach is suggesting that we can reduce time complexity by doubling the capacity of the array every time it is full. For instance if we have an array of initial capacity size 4 and we make it full then when attempting to add new data we would create a new array of size 8 and copy all the old elements to this new array and then add the new data.
The text further states that the time complexity for this approach is O(N).
Can someone please clarify how is the time complexity for the approach also O(N) ?