What are the performance tradeoffs between std::vector and std::list? In what scenario is a std::list more efficient?

Last updated 21 June 2026

  • std::vector stores elements contiguously: cache-friendly, O(1) random access, low overhead, but middle insert/erase is O(n) and growth can invalidate iterators.

  • std::list (doubly-linked) gives O(1) insert/erase at a known iterator, stable iterators, and splice(), but has no random access and poor cache locality from per-node allocations.

  • List wins only for many mid-sequence insertions/erasures where you already hold the iterator (especially with large/expensive-to-move elements) or heavy splicing. In practice vector often still wins due to cache effects.

  • https://www.interviewbit.com/data-structure-interview-questions/
  • https://www.interviewbit.com/linked-list-interview-questions/
  • https://www.geeksforgeeks.org/dsa/difference-between-vector-and-list/
  • https://www.interviewbit.com/snippet/d9956347b945b075a774/
All C++ interview questions