Skip to main content

7.3) Vectors vs Lists


Vector

  • Contiguous sequence of storage locations
  • Good for situations where the pattern of access to vector elements can vary and we need to be able to access all elements with equal efficiency
  • Poor performance when inserting or removing data within the vector - especially at front

List

  • Doubly-linked sequence of nodes, each containing an item of data and two pointers - one pointing to previous node, the other to the next
  • No longer possible to access all elements with equal efficiency; instead, we must follow the chain of pointers from head forwards or tail backwards until desired element is found
  • Insertion/removal anywhere in the list can be done very efficiently