Bloomberg LP Interview Question
Software Engineer / DevelopersA vector holds all data items in adjacent areas of memory, making transfer of the entire vector easy and insertion or deletion of items expensive when compared with lists. Lists hold items is disjoint areas of memory, making transfer of the entire list expensive but insertion and deletion of individual items relatively cheap.
Classic vectors are also fixed in size, and limited to N items, while lists can dynamically grow and shrink.
Vectors also offer indexed access to the element items. Lists don't. The classic vector's predecessor is an array.
Modern implementations of vectors often aim at providing similar characteristic, but the underlying data structure may in fact be a list or a hash, and those vectors typically support dynamic re-sizing.
vector usually means resizable array, it's a continuous chunk of memory. list usually means doubly linked list.
- goog July 30, 2010