Skip to interview prep
Apexed

2. Compare arrays and linked lists.

EasyData structures & algorithms

TechnicalAtlassian guide
Sources & context
Show model answer

Arrays store elements contiguously, so indexing is O(1) and they are cache-friendly, but inserting or deleting in the middle is O(n) because elements shift.

Linked lists store nodes with pointers, so insertion or deletion at a known node is O(1), but reaching the i-th element is O(n) and each node carries pointer overhead. In practice dynamic arrays win most of the time; linked lists suit frequent splicing such as an LRU cache.

Compare arrays and linked lists. — Software engineering interview question — Apexed