Skip to main content

How does a linked list differ from an array?

A linked list and an array are both data structures for storing a set of elements, but they are fundamentally organized differently. The key difference: an array stores elements sequentially, while a list is connected through a chain of references.


1. Placement in memory

CharacteristicArrayLinked list
Storing elementsIn contiguous memory cellsIn different places in memory, connected by references
Structure[1][2][3][4]`[1
Next elementDetermined by indexDetermined by a reference (next)

2. Accessing elements

OperationArrayLinked list
Access by indexO(1) - instant (address is computed)O(n) - need to walk from the start to the target element
Search by valueO(n)O(n)

Conclusion: an array is faster for frequent access to random elements.


3. Insertion and deletion

OperationArrayLinked list
Insertion/deletion in the middleO(n) - elements need to be shiftedO(1) - it is enough to reassign references
Insertion at the endO(1) or O(n) (depends on the implementation)O(1), if there is a reference to tail

Conclusion: a list is better when elements need to be added and removed frequently.


4. Size

ParameterArrayLinked list
SizeFixed (in classic arrays)Changes dynamically
MemoryEconomicalRequires more (to store references)

5. Practical difference

  • An array is convenient when access speed and memory predictability matter.
  • A list is convenient when flexibility, dynamic size change, and frequent insertions/deletions matter.

Summary:

An array is a fast structure for storing elements sequentially and accessing them quickly. A linked list is a flexible structure for dynamic data, where insertion and deletion operations matter, but access is slower.

Short Answer

Interview ready
Premium

A concise answer to help you respond confidently on this topic during an interview.