An array stores elements next to each other in memory, so you can read any element by index in constant time, but inserting or deleting in the middle means shifting elements along. A linked list stores nodes that each point to the next, so inserting or removing at a known position is constant time, but reaching the nth element means walking the list. In practice, dynamic arrays are the default because they are fast and cache friendly.
Why interviewers ask this
This classic fundamentals question checks whether you understand how data structures behave, not just their names. The interviewer wants the trade offs in access, insertion and memory, ideally with Big O. Mentioning that arrays are usually faster in practice because of how processor caches work, and naming a real situation where a linked list does make sense, shows thinking beyond the textbook.
How to structure your answer
- Explain how each is laid out in memory.
- Compare access, insertion and deletion costs.
- Mention memory overhead and cache behaviour.
- Give a sensible example of when you would use each.
Example answer
An array keeps its elements in one continuous block of memory, so I can jump straight to any index in constant time, which makes arrays great for lookups and looping. The cost is that inserting or deleting in the middle means shifting everything after that point, which is linear time, and a fixed size array has to be copied to grow. Most languages give you a dynamic array, like a Python list or a Java ArrayList, which handles the growing for you. A linked list stores each element in a separate node that holds a pointer to the next one. Inserting or removing a node is constant time if you already have a reference to the right spot, but reaching the nth element means walking from the head, which is linear, and each node uses extra memory for its pointer. In practice I default to a dynamic array, because its elements sit next to each other in memory, which processor caches handle very well. A linked list makes sense when you constantly add and remove at the ends, or for something like an LRU cache combined with a hash map.
Walking into this interview soon? GhostPilot listens to your live call, spots the question the moment it is asked, and puts a structured answer on your screen in real time. Try it on your next mock, or grab a $29 Session Pass, no subscription, for the real thing.
See how it worksFollow-up questions to expect
- How does a dynamic array grow, and what does that cost on average?
- How would you reverse a linked list?
- What is a doubly linked list useful for?
Related software engineering intern questions
Your interviewer will ask their own version of this. Paste your actual job description into the free Question Predictor and get the 20 questions that role is most likely to ask, with what each one is really probing.
Predict my questions