4 ms·
The CS101 implementation of a Vector is that the data is only moved when the size of the vector reaches k*a^n where n is an integer and a is usually 2. Then th
by nroets 3y ago
The CS101 implementation of a Vector is that the data is only moved when the size of the vector reaches k*a^n where n is an integer and a is usually 2.
Then the time it takes to move the vector to a new location is amortized as the vector grows. Then push() takes constant time.
So the CS101 is optimal for the study of computer science.