Counting element copies across n push_backs

std::vector doubles its capacity (allocates 2x space and copies all existing elements) whenever push_back would exceed current capacity. Starting from an empty vector, n consecutive push_back calls are made. What is the total number of element copies performed across all reallocations, and what does that imply about the amortized cost per push_back?

25 of 46 in Data Structures & Algorithms