Ambiguity in Amortized Analysis O(1)

Revision en1, by 0xA28, 2016-06-05 18:24:12

As I managed to understand, When we are dealing with some dynamic data structure which has an average cost of O(1) Amortized Analysis in push and pop operations like vector in c++, the vector takes constant time per each push till it reaches to the Nth push (N = current size reserved), in the Nth push it takes linear time to allocate a new space typically with double the old size, and pretty the same done in pop operations.

Now assume that we have a vector of N current reserved space with N — 1 elements, every time we push a new element into the vector then pop it again, is this done in a linear time to change the allocated space ? it seems not, but why ?

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en3 English 0xA28 2016-06-05 18:40:40 0 (published)
en2 English 0xA28 2016-06-05 18:30:34 32 (saved to drafts)
en1 English 0xA28 2016-06-05 18:24:12 708 Initial revision (published)