CPP - Vectors STL

Why did prateek sir that when 5th element is added to vector then size is increased to 8?

Insertion in vector is amortized to minimize the space occupied by the vector. The memory is dynamically allotted to the vector in the following way :


The space is doubled after the vector is full…thus maintaining the total time complexity of pushback to constant

Hey Amartya,
As you are not responding to this thread, I am marking your doubt as Resolved for now. Re-open it if required.

Please mark your doubts as resolved in your course’s “ Ask Doubt ” section, when your doubt is resolved.