Vectors
Dynamic arrays that automatically resize when capacity is exceeded, providing both array-like indexed access and automatic growth. Vectors combine array efficiency with linked list flexibility. Accessing elements by index is O(1), while insertion and deletion depend on position. Vectors are fundamental collection types in modern programming languages.
Formula
Amortised insertion = O(1); Index access = O(1); Mid-insertion = O(n)
Real World
Java's ArrayList works like a concert venue that doubles its seating every time it sells out — Spotify's backend uses Java ArrayLists to dynamically grow playlists as users add songs, avoiding the need to pre-allocate a fixed number of slots.
Exam Focus
If asked to compare vectors with arrays, always state both time complexities and mention the amortised cost of resizing.
How well did you know this?