Ambiguity in Data Structures with Amortized Analysis O(1) Operations

Правка en3, от 0xA28, 2016-06-05 18:40:40

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 ?

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en3 Английский 0xA28 2016-06-05 18:40:40 0 (published)
en2 Английский 0xA28 2016-06-05 18:30:34 32 (saved to drafts)
en1 Английский 0xA28 2016-06-05 18:24:12 708 Initial revision (published)