Vectors

In this lesson, we'll compare vectors with arrays and see how to use C++ STL Vector.

We'll cover the following...

Array vs Vector

Many times, you need a structure like an array that is dynamic in size. Vectors are dynamic arrays. Vectors, similar to an array, have contiguous memory allocation so that random access is O(1)O(1) for vectors as well.

One way to implement vectors using an array is to copy the array to a new array of double the size every time the first array is full. The amortized time complexity is ...