Data Structures & Algorithms · Interview question

What's the fundamental tradeoff between a linked list and an array?

A strong answer

They're mirror images. An array stores elements contiguously, giving O(1) random access (a[i] is address arithmetic) but O(n) insert/delete in the middle (you must shift everything after). A linked list chains nodes by pointers, giving O(1) insert/delete once you hold the relevant node (just rewire pointers, nothing moves) but O(n) access to the k-th element (you walk from the head; there's no random access). Linked lists also cost extra memory, a pointer (or two) per node, and traverse cache-unfriendly because nodes are scattered, whereas arrays are packed. So you choose by your dominant operation: arrays for indexed access and scanning, linked lists for frequent splicing where you already have the node, like removing a finished timer from a timer list.

What a weak answer sounds like

You know the answer. Do you know what gets you dinged?

Pro breaks down the answer most candidates actually give to this question — and the specific reason an interviewer marks it down. It’s the difference between sounding correct and sounding senior, on all 472 questions.

From the lesson

Linked Lists

Nodes chained by pointers: O(1) splice anywhere, O(n) search and no random access, and how embedded does them without a heap via static node pools and intrusive lists.

More Linked Lists questions

Browse all 472 interview questions