Squarepoint · CS Fundamentals
Choose Between an Array and a Linked List
TrueInterview
October 7, 2026 · 1 min read
Put arrays and linked lists side by side as implementation options. Describe their time complexity, memory layout, cache behavior, allocation overhead, and iterator or reference stability. Then choose a structure for each of the following scenarios and justify each choice:
- Many indexed reads over a collection that is mostly fixed.
- Frequent insertions right after a node that has already been located.
- A queue containing millions of small elements on current hardware.
Constraints & Assumptions
- Compare a contiguous dynamic array against a standard pointer-based singly or doubly linked list.
- Incorporate real constant factors instead of falling back only on asymptotic notation.
- Specify when the stated linked-list insertion cost leaves out the time required to find the node.
Clarifying Questions to Ask
- Is the collection size known ahead of time or bounded?
- Do references to existing elements need to remain valid after an insertion?
- Are insertions specified by an index or by a handle to an existing node?
- Is memory locality or per-element overhead the limiting resource?
Hint — Split lookup from mutation: An insertion is constant-time only once the place to insert has already been located.
What a Strong Answer Covers
- The costs of indexed access, traversal, insertion, deletion, and resizing.
- Contiguous storage and cache locality as opposed to pointer chasing.
- Per-node pointers, allocator overhead, and fragmentation.
- Nuanced choices for all three scenarios.
Follow-up Questions
- Why might a dynamic array outperform a linked list even when both operations are ?
- When does a deque provide an improvement over either choice for queue operations?
- How do intrusive lists change ownership and allocation trade-offs? Overview: Compare arrays and linked lists in terms beyond Big O notation. Address cache locality, allocation and pointer overhead, reference stability, and practical choices for indexed access, insertion, and queues.
Loading comments…